Skip to content

Commit c1cd1d7

Browse files
authored
docs: Add upgrade notice and migration entry for changes to GeneratedAnswer and ExtractedAnswer (#11896)
1 parent 344e909 commit c1cd1d7

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

MIGRATION.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ from haystack.dataclasses import Document
7373
doc = Document(content="col\n1\n2\n3")
7474
```
7575

76+
### `GeneratedAnswer` and `ExtractedAnswer` serialization format
77+
78+
**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.
79+
80+
**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.
81+
82+
**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).
83+
84+
Before (v2.x):
85+
```python
86+
serialized = generated_answer.to_dict()
87+
data = serialized["init_parameters"]["data"]
88+
```
89+
90+
After (v3.0):
91+
```python
92+
serialized = generated_answer.to_dict()
93+
data = serialized["data"]
94+
```
95+
7696
### Components Moved to External Packages
7797

7898
**What changed:** Some components have been moved out of Haystack into dedicated integration packages,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
upgrade:
3+
- |
4+
``GeneratedAnswer`` and ``ExtractedAnswer`` now serialize to the same flat format as
5+
all other Haystack dataclasses (``Document``, ``ChatMessage``, etc.). This is a breaking
6+
change: ``to_dict()`` no longer wraps the fields in the ``{"type": "...", "init_parameters":
7+
{...}}`` envelope and instead returns the fields at the top level. Any code or stored
8+
artifact that reads the serialized output and expects the ``type``/``init_parameters``
9+
keys must be updated to read the fields directly. ``from_dict()`` remains backward
10+
compatible and still accepts the old wrapped format.

0 commit comments

Comments
 (0)