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
+131Lines changed: 131 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -437,3 +437,134 @@ builder = PromptBuilder(
437
437
)
438
438
builder.run(name="John") # greeting renders as ""
439
439
```
440
+
441
+
### Generators removed
442
+
443
+
**What changed:**`OpenAIGenerator`, `AzureOpenAIGenerator`, `HuggingFaceAPIGenerator`, and `HuggingFaceLocalGenerator` have been removed.
444
+
Generators living in Haystack Core Integrations will also be removed soon.
445
+
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.
446
+
447
+
**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.
448
+
449
+
**How to migrate:**
450
+
451
+
#### Direct usage (running a generator from Python code)
452
+
453
+
Before (v2.x):
454
+
```python
455
+
from haystack.components.generators import OpenAIGenerator
456
+
457
+
gen = OpenAIGenerator()
458
+
result = gen.run("What is NLP?")
459
+
text = result["replies"][0] # str
460
+
meta = result["meta"][0] # dict with model metadata
461
+
```
462
+
463
+
After (v3.0):
464
+
```python
465
+
from haystack.components.generators.chat import OpenAIChatGenerator
466
+
467
+
gen = OpenAIChatGenerator()
468
+
result = gen.run("What is NLP?") # str input accepted directly
469
+
reply = result["replies"][0] # ChatMessage
470
+
text = reply.text # str
471
+
meta = reply.meta # dict with model metadata (now on the message)
472
+
```
473
+
474
+
#### System prompt
475
+
476
+
Before (v2.x):
477
+
```python
478
+
from haystack.components.generators import OpenAIGenerator
479
+
480
+
gen = OpenAIGenerator(system_prompt="You are concise.")
481
+
result = gen.run("What is NLP?")
482
+
```
483
+
484
+
After (v3.0):
485
+
```python
486
+
from haystack.components.generators.chat import OpenAIChatGenerator
487
+
from haystack.dataclasses import ChatMessage
488
+
489
+
gen = OpenAIChatGenerator()
490
+
result = gen.run([
491
+
ChatMessage.from_system("You are concise."),
492
+
ChatMessage.from_user("What is NLP?"),
493
+
])
494
+
```
495
+
496
+
#### Pipeline usage
497
+
498
+
Pipelines that connected `PromptBuilder` (output: `str`) to a legacy Generator continue to work unchanged when you swap in a ChatGenerator. The Haystack pipeline type system automatically converts `str` to `list[ChatMessage]` at the connection edge.
499
+
500
+
Before (v2.x):
501
+
```python
502
+
from haystack.components.generators import OpenAIGenerator
503
+
from haystack.components.builders import PromptBuilder
Legacy Generators exposed a second output socket `meta: list[dict]`. ChatGenerators do not; per-reply metadata is embedded in each `ChatMessage.meta`. If you had a pipeline connection to `llm.meta`, remove it. `AnswerBuilder` already handles this automatically (it reads metadata from `ChatMessage.meta` when the replies are `list[ChatMessage]`).
# no meta connection needed; AnswerBuilder reads it from ChatMessage.meta
546
+
```
547
+
548
+
### `DALLEImageGenerator` renamed to `OpenAIImageGenerator`
549
+
550
+
**What changed:**`DALLEImageGenerator` has been renamed to `OpenAIImageGenerator` and moved to `haystack.components.generators.openai_image_generator`. The API and parameters are otherwise unchanged.
551
+
552
+
**Why:** OpenAI retired the DALL-E model family. The new name reflects that the component works with the full OpenAI image generation API and is no longer tied to a specific model family.
553
+
554
+
**How to migrate:**
555
+
556
+
Before (v2.x):
557
+
```python
558
+
from haystack.components.generators import DALLEImageGenerator
559
+
560
+
generator = DALLEImageGenerator(model="dall-e-3")
561
+
result = generator.run("A photo of a red apple")
562
+
```
563
+
564
+
After (v3.0):
565
+
```python
566
+
from haystack.components.generators import OpenAIImageGenerator
0 commit comments