From 63540f727ab1fcccb17fc98fff8c1b3a9c6f78a3 Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Fri, 10 Jul 2026 10:51:37 +0200 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20correct=20MIGRATION.md=20=E2=80=94?= =?UTF-8?q?=20remove=20Answer=20serialization=20entry=20not=20on=20main,?= =?UTF-8?q?=20fix=20Generators-removed=20replacements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- MIGRATION.md | 22 +------------------ ...-dataclasses-deseria-0bb839b5edd3fca6.yaml | 10 --------- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml diff --git a/MIGRATION.md b/MIGRATION.md index dce8a569b2a..1b249b876f5 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -73,26 +73,6 @@ from haystack.dataclasses import Document doc = Document(content="col\n1\n2\n3") ``` -### `GeneratedAnswer` and `ExtractedAnswer` serialization format - -**What changed:** `GeneratedAnswer.to_dict()` and `ExtractedAnswer.to_dict()` now return a flat dictionary of the object's fields instead of wrapping them in a `{"type": ..., "init_parameters": {...}}` envelope. `from_dict()` still accepts the old wrapped format, so existing serialized artifacts keep loading. - -**Why:** Aligns these dataclasses with how every other Haystack dataclass (`Document`, `ChatMessage`, etc.) serializes, and removes redundant type metadata from pipeline snapshots and `State` objects. - -**How to migrate:** Update any code that reads the serialized output to access fields at the top level instead of under `init_parameters`. See [#11805](https://github.com/deepset-ai/haystack/pull/11805). - -Before (v2.x): -```python -serialized = generated_answer.to_dict() -data = serialized["init_parameters"]["data"] -``` - -After (v3.0): -```python -serialized = generated_answer.to_dict() -data = serialized["data"] -``` - ### Components Moved to External Packages **What changed:** Some components have been moved out of Haystack into dedicated integration packages, @@ -846,7 +826,7 @@ Patterns are matched as prefixes by default (`"mypkg"` matches `mypkg` and any s **What changed:** `OpenAIGenerator`, `AzureOpenAIGenerator`, `HuggingFaceAPIGenerator`, and `HuggingFaceLocalGenerator` have been removed. Generators living in Haystack Core Integrations will also be removed soon. -Their chat counterparts (`OpenAIChatGenerator`, `AzureOpenAIChatGenerator`, `HuggingFaceAPIChatGenerator`, `HuggingFaceLocalChatGenerator`) are the replacement. As of Haystack 3.0, all ChatGenerators also accept a plain `str` as input, so the migration rarely requires structural changes. +Their chat counterparts are the replacement: `OpenAIChatGenerator` and `AzureOpenAIChatGenerator` in Haystack core, `HuggingFaceAPIChatGenerator` in the `huggingface-api-haystack` integration, and `TransformersChatGenerator` (the renamed `HuggingFaceLocalChatGenerator`) in the `transformers-haystack` integration (see [Components Moved to External Packages](#components-moved-to-external-packages)). As of Haystack 3.0, all ChatGenerators also accept a plain `str` as input, so the migration rarely requires structural changes. **Why:** Over time, Generators became shallow wrappers over the ChatGenerators, converting `str → ChatMessage → str` around the exact same model calls. All new features (tool calling, structured outputs, etc.) were introduced only in ChatGenerators, leaving the legacy classes behind. They were also a source of confusion for newcomers and an unnecessary duplication of code and tests. diff --git a/releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml b/releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml deleted file mode 100644 index 567cca034db..00000000000 --- a/releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -upgrade: - - | - ``GeneratedAnswer`` and ``ExtractedAnswer`` now serialize to the same flat format as - all other Haystack dataclasses (``Document``, ``ChatMessage``, etc.). This is a breaking - change: ``to_dict()`` no longer wraps the fields in the ``{"type": "...", "init_parameters": - {...}}`` envelope and instead returns the fields at the top level. Any code or stored - artifact that reads the serialized output and expects the ``type``/``init_parameters`` - keys must be updated to read the fields directly. ``from_dict()`` remains backward - compatible and still accepts the old wrapped format. From fa019a8c01d24fb53e68d0baed2509fee4c0ba60 Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Sat, 11 Jul 2026 09:52:07 +0200 Subject: [PATCH 2/2] docs: restore Answer serialization migration entry and release note (#11805 is being re-landed) Co-Authored-By: Claude Fable 5 --- MIGRATION.md | 20 +++++++++++++++++++ ...-dataclasses-deseria-0bb839b5edd3fca6.yaml | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml diff --git a/MIGRATION.md b/MIGRATION.md index 1b249b876f5..1993b37f71c 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -73,6 +73,26 @@ from haystack.dataclasses import Document doc = Document(content="col\n1\n2\n3") ``` +### `GeneratedAnswer` and `ExtractedAnswer` serialization format + +**What changed:** `GeneratedAnswer.to_dict()` and `ExtractedAnswer.to_dict()` now return a flat dictionary of the object's fields instead of wrapping them in a `{"type": ..., "init_parameters": {...}}` envelope. `from_dict()` still accepts the old wrapped format, so existing serialized artifacts keep loading. + +**Why:** Aligns these dataclasses with how every other Haystack dataclass (`Document`, `ChatMessage`, etc.) serializes, and removes redundant type metadata from pipeline snapshots and `State` objects. + +**How to migrate:** Update any code that reads the serialized output to access fields at the top level instead of under `init_parameters`. See [#11805](https://github.com/deepset-ai/haystack/pull/11805). + +Before (v2.x): +```python +serialized = generated_answer.to_dict() +data = serialized["init_parameters"]["data"] +``` + +After (v3.0): +```python +serialized = generated_answer.to_dict() +data = serialized["data"] +``` + ### Components Moved to External Packages **What changed:** Some components have been moved out of Haystack into dedicated integration packages, diff --git a/releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml b/releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml new file mode 100644 index 00000000000..567cca034db --- /dev/null +++ b/releasenotes/notes/fix-dataclasses-deseria-0bb839b5edd3fca6.yaml @@ -0,0 +1,10 @@ +--- +upgrade: + - | + ``GeneratedAnswer`` and ``ExtractedAnswer`` now serialize to the same flat format as + all other Haystack dataclasses (``Document``, ``ChatMessage``, etc.). This is a breaking + change: ``to_dict()`` no longer wraps the fields in the ``{"type": "...", "init_parameters": + {...}}`` envelope and instead returns the fields at the top level. Any code or stored + artifact that reads the serialized output and expects the ``type``/``init_parameters`` + keys must be updated to read the fields directly. ``from_dict()`` remains backward + compatible and still accepts the old wrapped format.