4143 Commits

Author SHA1 Message Date
Sebastian Husch Lee
ff56363db1
fix: In set_output_types check that the decorator @component.output_types is not present on the run_async method (#9485)
* Fix

* Add reno
2025-06-04 12:17:47 +02:00
Stefano Fiorucci
1e2214a1a0
feat: ChatMessage.to_openai_dict_format - add require_tool_call_ids parameter (#9481) 2025-06-03 16:55:13 +02:00
Sebastian Husch Lee
ce0917e586
feat: Add raise_on_failure boolean parameter to OpenAIDocumentEmbedder and AzureOpenAIDocumentEmbedder (#9474)
* Add raise_on_failure to OpenAIDocumentEmbedder

* Add reno

* Add parameter to Azure Doc embedder as well

* Fix bug

* Update reno

* PR comments

* update reno
2025-06-03 10:22:34 +00:00
Sebastian Husch Lee
5fcd7c4732
feat: Allow passing of additional parameters to HF Inference clients in HuggingFaceAPIChatGenerator and HuggingFaceAPIGenerator (#9457)
* Fix tests by allowing passing of provider

* Add reno

* Fix mypy

* Update release note
2025-06-03 10:21:51 +00:00
Sebastian Husch Lee
12e3de364a
Fix test (#9475) 2025-06-03 08:00:10 +00:00
David S. Batista
b85c8e3382
feat: adding deserialize_component_inplace() (#9459)
* adding tests

* adding release notes

* deserialize_chatgenerator_inplace uses deserialize_component_inplace

* removing tests
2025-06-02 09:40:35 +02:00
Sebastian Husch Lee
25c8d7ef9a
fix: In State schema validation use != instead of is not for checking the type of messages (#9454)
* Use != instead of is not

* Add reno

* Use more == instead of is

* Fix mypy
2025-05-30 10:07:37 +02:00
Stefano Fiorucci
2616d4d55b
test: speed up some tests + minor refactorings (#9451)
* this is an integration test

* more improvements

* rm redundant comments
2025-05-29 09:49:11 +02:00
Sebastian Husch Lee
81c0cefa41
refactor: Refactor hf api chat generator (#9449)
* Refactor HFAPI Chat Generator

* Add component info to generators

* Fix type hint

* Add reno

* Fix unit tests

* Remove incorrect dev comment

* Move _convert_streaming_chunks_to_chat_message to utils file
2025-05-27 15:55:06 +02:00
atopx
3deaa20cb6
feat: Add HuggingFace API (text-embeddings-inference for rerank model) for component.rankers (#9414)
* feat(component.rankers): Add HuggingFace API (text-embeddings-inference for rerank) ranker component

* update test flow & doc loaders

* Support run_async for HuggingFaceAPIRanker

* Add release note for HuggingFace API support in component.rankers

* Add release note for HuggingFace API support in component.rankers

* Add release note for HuggingFace API support in component.rankers

* Add release note for HuggingFace API support in component.rankers

* fix:
1. `hugging_face_api.HuggingFaceAPIRanker` rename to `hugging_face_tei.HuggingFaceAPIRanker`
2. HuggingFaceAPIRanker: use our Secret API for token
3. add the missing modules for `docs/pydoc/config/rankers_api.yml`
4. added function `async_request_with_retry` for `haystack/utils/requests_utils.py` and added unittest on `test/utils/test_requests_utils.py`
4. HuggingFaceAPIRanker: refactor the retry function to support configuration based on attempts and status code.
5. HuggingFaceAPIRanker: refactor the test into unit tests using mocks

* fix(HuggingFaceTEIRanker): change the token check logic to use the resolve_value method.

* fix(format): run `hatch run format`

* fix:
- Force keyword-only arguments in __init__ method by adding *,
- Clarify token docstring that it's not always required
- Copy documents to avoid modifying original objects
- Remove test file from slow workflow
- Add monkeypatch eånvironment variable cleanup in tests
- Fix missing module in rankers_api.yml and sort modules alphabetically
- Remove unnecessary test info from release notes

* fix HuggingFaceTEIRanker:
- "None" of "Optional[Secret]" has no attribute "resolve_value"
- run/run_async: too many parameters

* fix(HuggingFaceTEIRanker) :Revise the docstring of the HuggingFaceTEIRanker, improve the parameter descriptions, ensure consistency and clarity. Add error handling information to enhance the readability of the API response.

* fix:unit test for HuggingFaceTEIRanker raise message

* fix fmt

* minor refinements

* refine release note

---------

Co-authored-by: anakin87 <stefanofiorucci@gmail.com>
2025-05-27 12:44:54 +02:00
Sebastian Husch Lee
db3d95b12a
refactor: Refactor openai generator (#9445)
* Refactor openai generator and chat generator to reusue same util methods

* Start fixing tests

* More fixes

* Fix mypy

* Fix
2025-05-27 12:44:17 +02:00
Amna Mubashar
64def6d41b
feat: add component name and type to StreamingChunk (#9426)
* Stream component name in openai

* Fix type

* PR comments

* Update huggingface gen

* Typing fix

* Update huggingfacelocal gen

* Fix errors

* Remove model changes

* Fix minor errors

* Update releasenotes/notes/add-component-info-dataclass-be115dee2fa50abd.yaml

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>

* PR comments

* update annotation

* Update hf files

* Fix linting

* Add a from_component method

* use add_component

---------

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
2025-05-27 12:23:40 +02:00
Stefano Fiorucci
085c3add41
ci: prevent DocumentWriter tests from blocking CI (#9448) 2025-05-27 12:10:21 +02:00
Stefano Fiorucci
d8487c4d8d
chore: make mypy run with --check-untyped-defs; fix some errors (#9447)
* chore: make mypy run with --check-untyped-defs; fix some errors

* small fixes

* use HfPipeline

* fix license error
2025-05-27 07:35:25 +00:00
David S. Batista
da60156174
chore: removing unused imports from tests (#9446) 2025-05-26 16:22:51 +00:00
David S. Batista
2092bedb90
chore: removing unused imports from tests (#9444) 2025-05-26 13:41:36 +00:00
Sebastian Husch Lee
b8dff93200
chore: Fix Streaming Callback types (#9441)
* Fix types

* Add select_streaming_callback
2025-05-26 15:39:59 +02:00
David S. Batista
c82a3377f2
chore: cleaning up tests (#9443) 2025-05-26 15:12:19 +02:00
Stefano Fiorucci
802328e292
chore: drop python>=3.9 check in type serialization (#9439)
Co-authored-by: David S. Batista <dsbatista@gmail.com>
2025-05-26 09:40:54 +00:00
Denis Washington
eefda0452d
chore: Make the Haystack core "type complete" (#9438)
* chore: Make the Haystack core "type complete"

For libraries with a `py.typed` marker, it is [recommended][1] to
make all public interfaces "type complete", i.e. to explicitly
annotate all function parameters and return types. Doing so has the
following benefits:

- It maximizes the type information available to users and IDEs.
- It ensures that the argument and return types are the intended ones.
- It sidesteps differences in type inference between the different
  type checker implementations.

This change makes a first step towards type completeness by enabling
the Mypy `disallow_incomplete_defs` for the core modules (excluding
`haystack.components.*` and `haystack.testing.*`) and fixing the
resulting errors.

[1]: https://typing.python.org/en/latest/guides/libraries.html#how-much-of-my-library-needs-types

* chore: Add `python_version = 3.9` to Mypy config

This catches type constructs that are only supported in later Python
versions.

* Remove unused import

* try to fix linting

---------

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
2025-05-26 11:00:22 +02:00
Sebastian Husch Lee
0d23fe7f0d
fix: Fix invoker to work when using dataclass with from_dict but dataclass… (#9434)
* Fix invoker to work when using dataclass with from_dict but dataclass is already given

* add reno

* Add unit test

* Remove line
2025-05-26 09:40:09 +02:00
Seth Peters
f025501792
fix: LLMMetadataExtractor bug in handling Document objects with no content
* test(extractors): Add unit test for LLMMetadataExtractor with no content

Adds a new unit test `test_run_with_document_content_none` to `TestLLMMetadataExtractor`.

This test verifies that `LLMMetadataExtractor` correctly handles documents where `document.content` is None or an empty string.

It ensures that:

- Such documents are added to the `failed_documents` list.

- The correct error message ("Document has no content, skipping LLM call.") is present in their metadata.

- No actual LLM call is attempted for these documents.

This test provides coverage for the fix that prevents an AttributeError when processing documents with no content.

* chore: update comment to reflect new behavior in _run_on_thread method

* docs: Add release note for LLMMetadataExtractor no content fix

* Update releasenotes/notes/fix-llm-metadata-extractor-no-content-910067ea72094f18.yaml

* Update fix-llm-metadata-extractor-no-content-910067ea72094f18.yaml

---------

Co-authored-by: David S. Batista <dsbatista@gmail.com>
2025-05-23 18:57:39 +02:00
Haystack Bot
1fb2477149
chore: Update unstable version to 2.15.0-rc0 (#9437)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-05-23 16:46:27 +02:00
David S. Batista
81425afe22
typing: typing for SuperComponents public methods (#9420)
* adding stub files for the supercomponents in haystack

* adding LICENSE to stub files

* fixing

* fixing no member issue

* fixing no member issue #2

* wip

* makying static analyzers happy

* adding alternative to stubs for all SuperComponents + tests

* Update haystack/components/converters/multi_file_converter.py

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>

* Update haystack/components/preprocessors/document_preprocessor.py

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>

* removing tests + left stub

* fixing run typing

* making the fake run keyword arguments only

* extend fake to all user callable methods

* fixing async run signature

* fixing async run signature

* removing async

---------

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
v2.15.0-rc0
2025-05-23 13:57:05 +00:00
Sebastian Husch Lee
33115bcccb
fix: Copy context when using ThreadPoolExecutor in `AsyncPipeline.run_async (#9433)
* Copy context when using threadpoolexecutor in AsyncPipeline.run_async

* Add reno

* Add dev comment
2025-05-23 15:11:08 +02:00
David S. Batista
d8cc6f7339
chore: removing an invalid arg from pipeline.base.PipelineBase.connect() docstring 2025-05-23 14:48:41 +02:00
Sebastian Husch Lee
6f5b745d0d
feat: Improve formatting in print streaming chunk (#9431)
* Improve formatting in print streaming chunk

* Add reno

* Fix mypy

* PR comments
2025-05-23 12:22:03 +00:00
Amna Mubashar
720cc19d7d
feat: add serialization to State / move State to agents.state (#9345)
* Add serialization to State

* Add release notes

* Deprecate State in dataclasses

* Fix tests

* Remove state_utils test

* Fix linting

* Fix formating

* Update tests and remove old state utils

* Update agents test

* Update deserilaization per review

* Linting

* Add tests for edge case (custom class types)

* Fix type serialization

* PR comments

* Move State to agents

* Fix tests

* Update utils init

* Improve seriliaztion/deser

* Update the release notes

* Minor fix in docstrings

* PR comments

* Add deprecation warnign for state utils

* Recreate the serialization methods to use schema

* Update key names

* Make serialization methods private
2025-05-23 11:04:15 +02:00
David S. Batista
3342f17f01
feat: draw/show SuperComponents in detail, expand it and show it's internal components in the visualisation diagram (#9389)
* initial import

* small fixes

* adding tests

* adding tests

* refactoring merge graphs

* updating tests

* docstrings

* adding release notes

* adding SuperComponent name to extended components

* adding colours and legend to different super components

* adding missed docstring parameter

* fixing tests and type checking

* Update haystack/core/pipeline/base.py

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>

* forcing keyword arguments for draw() and show()

* adding wrapper function and a deprecation warning

* adding pylint disable - this will be removed soon

* wip

* adding a decorator function to test if another function is being called with positional arguments

* adding a decorator function to test if another function is being called with positional arguments

---------

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
2025-05-23 10:21:44 +02:00
David S. Batista
ba41696bba
chore: removing unused fixtures in test functions 2025-05-23 09:43:01 +02:00
Mohammed Abdul Razak Wahab
4a5e4d3e65
feat: return common type in SuperComponent type compatibility check (#9275)
* feat: return common type in SuperComponent type compatibility check

* fix test_utils

* address review comments

* update tests

* use typing module types

* refactor

* refactor

* unenforce type check

* refactor

---------

Co-authored-by: Michele Pangrazzi <xmikex83@gmail.com>
2025-05-22 12:35:31 +00:00
Vladimir Blagojevic
167229f328
feat: Extend AnswerBuilder for Agent (#9406)
* Extend AnswerBuilder for Agent

* Update tests

* Add reno note

* PR feedback

* Add a better unit test

* Update haystack/components/builders/answer_builder.py

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>

* Update haystack/components/builders/answer_builder.py

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>

* PR feedback

* Remove copy

---------

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
2025-05-22 14:32:36 +02:00
Sebastian Husch Lee
e6a53b9dca
fix: Add missing timeout and max_retries to OpenAITextEmbedder and OpenAIDocumentEmbedder (#9421)
* Add missing params to to_dict for OpenAI embedders

* add reno

* Track variable internally instead of using client
2025-05-22 09:19:14 +00:00
Stefano Fiorucci
17432f710d
feat: introduce SentenceTransformersSimilarityRanker (#9415)
* new component + tests

* soft deprecation of TransformersSimilarityRanker + reno

* add comp files to slow workflow

* Apply suggestions from code review

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>

* self.model -> self._cross_encoder

* recommend installing sentence-transformers>=4.1.0

---------

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
2025-05-21 10:52:46 +02:00
Amna Mubashar
995fa18607
feat: stream ToolResult from run_async in Agent (#9407)
* Add async run

* Add release notes

* Update the run async

* Fixes

* Fix linting

* Add tests

* Fix tests

* Remove changes from Tool

* Linting updates

* Update haystack/components/tools/tool_invoker.py

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>

* Updates tests based on comments

* Update release notes

---------

Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
2025-05-21 10:22:38 +02:00
Vladimir Blagojevic
f253db3e14
feat: ComponentTool - preserve docstrings from underlying pipeline components (#9403)
* ComponentTool - preserve docstrings from underlying pipeline components

* PR feedback, adjustments
2025-05-20 13:11:49 +02:00
Stefano Fiorucci
6ad23f822f
ci: add timeout-minutes to relevant CI jobs (#9409) 2025-05-20 09:23:42 +02:00
Jan Trienes
83b087caf4
feat: add local_files_only to sentence-transformers embedders (#9400)
* feat: add  to sentence-transformers embedders

* add release note

* Fix wording

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>

---------

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
2025-05-19 16:11:49 +00:00
Stefano Fiorucci
fab9e0d792
chore: run mypy --check-untyped-defs and fix some errors (#9398)
* first batch of fixes

* more fixes

* more fixes

* revert HuggingFaceLocalChatGenerator
2025-05-19 17:51:24 +02:00
Sebastian Husch Lee
707573d967
feat: Streamline using Agent as a ComponentTool (#9388)
* Make agent as a tool more streamlined

* Add reno

* fix mypy
2025-05-16 13:11:43 +02:00
dependabot[bot]
3e28ec207a
chore(deps): bump fossas/fossa-action from 1.6.0 to 1.7.0 (#9392)
Bumps [fossas/fossa-action](https://github.com/fossas/fossa-action) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/fossas/fossa-action/releases)
- [Commits](https://github.com/fossas/fossa-action/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: fossas/fossa-action
  dependency-version: 1.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-16 11:22:30 +02:00
Denis Washington
954b0d1033
fix: Improve typing of @component and allow TypedDict output types (#9396)
- Add type annotations to the `_Component.__call__` function that
  backs `@component`. This fixes "decorator ignored" warnings of
  Pyright in "strict" type-checking mode.

- Type-check that a `@component` class conforms to the `Component`
  protocol (i.e., that it has a `run()` method).

- Relax the `run()` return type required by the `Component` protocol
  from `Dict[str, Any]` to `Mapping[str, Any]`. The former is
  incompatible with `TypedDict`, which makes it impossible to
  type a component's precise outputs. `Mapping` fixes this because
  it is covariant, i.e. the value type may be more specific than
  `Any`.
2025-05-16 09:15:20 +02:00
Daria Fokina
2a64cd4e9a
docs: update ChatMessage examples (#9394) 2025-05-15 17:23:37 +02:00
David S. Batista
d8ff508c44
chore: removing warning and using permute to reverse the dimensions of a tensor (#9393)
* using permute to reverse the dimensions of a tensor
2025-05-15 16:56:09 +02:00
Sebastian Husch Lee
af073852d0
feat: Add usage when using HuggingFaceAPIChatGenerator with streaming (#9371)
* Small fix and update tests

* Add usage support to streaming for HuggingFaceAPIChatGenerator

* Add reno

* try using provider='auto'

* Undo provider

* Fix unit tests

* Update releasenotes/notes/add-usage-hf-api-chat-streaming-91fd04705f45d5b3.yaml

Co-authored-by: Julian Risch <julian.risch@deepset.ai>

---------

Co-authored-by: anakin87 <stefanofiorucci@gmail.com>
Co-authored-by: Julian Risch <julian.risch@deepset.ai>
2025-05-15 13:09:36 +02:00
Sebastian Husch Lee
9ae76e1653
Fix component tool parameters (#9342)
* Starting property schema refactor

* Adding more tests

* More tests

* Handle null type explicitly

* More updates of tests to accomodate Optional properly

* Fix more tests

* Remove unecessary check

* Some cleanup

* Update test

* Add reno

* Fix typing

* Add license header

* Use docstrings of dataclasses in parameter spec generation

* More tests of Haystack dataclass types

* Properly handle Sequence

* Fix license header

* Update OpenAI tests to add more complicated tool parameter signature

* Properly set required for dataclasses

* Add integration test for azure that includes additionalProperties

* Add more complicated integration test for HuggingFaceAPIChatGenerator

* Alternate approach using pydantic like we do in from_function.py

* Cleanup and fix other affected tests

* Fix mypy

* PR comments

* PR comment

* Remove test from HF API

* Update reno

* Update reno
2025-05-15 07:51:06 +00:00
David S. Batista
42b378950f
fix: DocumentRecallEvaluator changing division and adding checks for emptiness of documents (#9380)
* changing division and adding checks for emptiness of documents

* adding release notes

* adding tests

* Update releasenotes/notes/updated-doc-recall-eval-uniqueness-59b09082cf8e7593.yaml

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>

* attending PR comments

* Update releasenotes/notes/updated-doc-recall-eval-uniqueness-59b09082cf8e7593.yaml

* Update releasenotes/notes/updated-doc-recall-eval-uniqueness-59b09082cf8e7593.yaml

Co-authored-by: Julian Risch <julian.risch@deepset.ai>

* Update haystack/components/evaluators/document_recall.py

Co-authored-by: Julian Risch <julian.risch@deepset.ai>

* Update haystack/components/evaluators/document_recall.py

Co-authored-by: Julian Risch <julian.risch@deepset.ai>

* Update haystack/components/evaluators/document_recall.py

Co-authored-by: Julian Risch <julian.risch@deepset.ai>

* Update haystack/components/evaluators/document_recall.py

Co-authored-by: Julian Risch <julian.risch@deepset.ai>

* adding tests

* linting

---------

Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
Co-authored-by: Julian Risch <julian.risch@deepset.ai>
2025-05-14 11:37:47 +02:00
Daria Fokina
aeea3b2d39
dC to dAP (#9383) 2025-05-13 18:03:51 +02:00
Stefano Fiorucci
1541d93670
chore: remove deprecated deserialize tools inplace function (#9379)
* rm deserialize_tools_inplace + clean up

* release note
2025-05-13 09:27:36 +02:00
Sebastian Husch Lee
9f2c0679d4
Small fix and update tests (#9370) 2025-05-12 22:02:26 +02:00