You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,13 @@ This document is meant to provide a guide for migrating from Haystack v2.X to v3
8
8
9
9
### `GeneratedAnswer` and `ExtractedAnswer` serialization format
10
10
11
-
**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.
11
+
**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.
12
12
13
13
**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.
14
14
15
-
**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).
15
+
**Deserialization is backward compatible:**`from_dict()` accepts both the new flat format and the old wrapped `{"type": ..., "init_parameters": {...}}` format, so existing serialized artifacts (pipeline snapshots, breakpoints, `State` objects) keep loading without any changes on your side.
16
+
17
+
**How to migrate:** Only code that *reads* the serialized output needs updating: access fields at the top level instead of under `init_parameters`. Code that deserializes with `from_dict()` needs no changes.
16
18
17
19
Before (v2.x):
18
20
```python
@@ -24,6 +26,10 @@ After (v3.0):
24
26
```python
25
27
serialized = generated_answer.to_dict()
26
28
data = serialized["data"]
29
+
30
+
# Deserialization still accepts both the new and the old format:
31
+
GeneratedAnswer.from_dict(serialized) # new flat format
32
+
GeneratedAnswer.from_dict(old_wrapped_dict) # old {"type": ..., "init_parameters": {...}} format
0 commit comments