Skip to content

Commit 7cf3769

Browse files
julian-rischclaude
andauthored
docs: replace removed non-chat Generators with ChatGenerators (#590)
* docs: replace removed non-chat Generators with ChatGenerators Swap the Generator components removed in Haystack 3.0 and the core-integration Generators being removed for their ChatGenerator equivalents across 33 integration pages; note that lmformatenforcer only works with Haystack 2.x. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs: replace retired OpenAI model names in migrated examples with gpt-4.1-mini Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 02adaa7 commit 7cf3769

33 files changed

Lines changed: 134 additions & 202 deletions

‎integrations/alphai.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ for doc in fetcher.run()["documents"]:
8484
```python
8585
from haystack import Pipeline
8686
from haystack.components.builders import PromptBuilder
87-
from haystack.components.generators import OpenAIGenerator
87+
from haystack.components.generators.chat import OpenAIChatGenerator
8888

8989
from alphai_haystack import AlphaAINewsFetcher
9090

@@ -97,12 +97,12 @@ template = """Summarize what moved {{ symbol }} today, using only these articles
9797
pipeline = Pipeline()
9898
pipeline.add_component("news", AlphaAINewsFetcher(min_relevance=6, collapse_stories=True))
9999
pipeline.add_component("prompt", PromptBuilder(template=template))
100-
pipeline.add_component("llm", OpenAIGenerator(model="gpt-4o-mini"))
100+
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini"))
101101
pipeline.connect("news.documents", "prompt.documents")
102102
pipeline.connect("prompt", "llm")
103103

104104
result = pipeline.run({"news": {"symbol": "NVDA"}, "prompt": {"symbol": "NVDA"}})
105-
print(result["llm"]["replies"][0])
105+
print(result["llm"]["replies"][0].text)
106106
```
107107

108108
Both components serialize with the rest of the pipeline (`to_dict` / `from_dict`); the API key

‎integrations/amazon-bedrock.md‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pip install amazon-bedrock-haystack
3636

3737
## Usage
3838

39-
Once installed, you will have access to [AmazonBedrockChatGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockchatgenerator) and [AmazonBedrockGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockgenerator) components that support generative language models on Amazon Bedrock.
39+
Once installed, you will have access to the [AmazonBedrockChatGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockchatgenerator) component that supports generative language models on Amazon Bedrock.
4040
You will also have access to the [AmazonBedrockTextEmbedder](https://docs.haystack.deepset.ai/docs/amazonbedrocktextembedder) and [AmazonBedrockDocumentEmbedder](https://docs.haystack.deepset.ai/docs/amazonbedrockdocumentembedder), which can be used to compute embeddings.
4141
The integration also includes [S3Downloader](https://docs.haystack.deepset.ai/docs/s3downloader) that allows downloading files from AWS S3 buckets to the local filesystem.
4242

@@ -88,22 +88,6 @@ Output:
8888
{'replies': [ChatMessage(_role=<ChatRole.ASSISTANT: 'assistant'>, _content=[TextContent(text='El procesamiento del lenguaje natural (PLN) es una rama de la inteligencia artificial que permite a las computadoras comprender, interpretar y generar lenguaje humano.')], _name=None, _meta={'model': 'amazon.nova-pro-v1:0', 'index': 0, 'finish_reason': 'end_turn', 'usage': {'prompt_tokens': 21, 'completion_tokens': 31, 'total_tokens': 52}})]}
8989
```
9090

91-
### AmazonBedrockGenerator
92-
93-
Most [supported models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) can be used with `AmazonBedrockGenerator`, but we highly recommend using the `AmazonBedrockChatGenerator` instead.
94-
95-
```python
96-
from haystack_integrations.components.generators.amazon_bedrock import AmazonBedrockGenerator
97-
98-
generator = AmazonBedrockGenerator(model="mistral.mixtral-8x7b-instruct-v0:1")
99-
result = generator.run("Who is the best American actor?")
100-
print(result)
101-
```
102-
Output:
103-
```shell
104-
{'replies': ['It\'s subjective to determine the "best" American actor as it depends on personal preferences, critical acclaim, and the impact of their work. However, some of the most renowned and influential American actors include:\n\n1. Daniel Day-Lewis - Known for his versatility and commitment to his roles, Day-Lewis is a three-time Academy Award winner for Best Actor.\n2. Meryl Streep - With a record 21 Academy Award nominations and three wins, Streep is widely regarded as one of the greatest actresses in American film history.\n3. Jack Nicholson - A three-time Academy Award winner and 12-time nominee, Nicholson is known for his iconic roles in films like "One Flew Over the Cuckoo\'s Nest," "Terms of Endearment," and "As Good as It Gets."\n4. Robert De Niro - A two-time Academy Award winner, De Niro is known for his collaborations with Martin Scorsese and his memorable roles in films like "Taxi Driver," "Raging Bull," and "The Godfather: Part II."\n5. Leonardo DiCaprio - A four-time Academy Award nominee and one-time winner, DiCaprio has had a successful career in both blockbusters and independent films.\n\nThese are just a few examples of highly acclaimed American actors, and there are many other talented actors who could be considered for this title.'], 'meta': {'RequestId': 'ed9c8566-0b13-4c08-ba72-c88be1aecd02', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Mon, 28 Apr 2025 11:00:15 GMT', 'content-type': 'application/json', 'content-length': '1322', 'connection': 'keep-alive', 'x-amzn-requestid': 'ed9c8566-0b13-4c08-ba72-c88be1aecd02', 'x-amzn-bedrock-invocation-latency': '7065', 'x-amzn-bedrock-output-token-count': '323', 'x-amzn-bedrock-input-token-count': '16'}, 'RetryAttempts': 0}}
105-
```
106-
10791
### Embedders
10892

10993
Three components are available for using embedding models with Amazon Bedrock: [`AmazonBedrockTextEmbedder`](https://docs.haystack.deepset.ai/docs/amazonbedrocktextembedder), [`AmazonBedrockDocumentEmbedder`](https://docs.haystack.deepset.ai/docs/amazonbedrockdocumentembedder) and [`AmazonBedrockDocumentImageEmbedder`](https://docs.haystack.deepset.ai/docs/amazonbedrockdocumentimageembedder).

‎integrations/anthropic.md‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ toc: true
2727

2828
This integration supports Anthropic Claude models such as Claude Haiku 3.5, Claude Sonnet 3.7, and Claude Sonnet 4.5 through Anthropic’s inference infrastructure. For a complete list of available models, check out [the Anthropic Claude documentation](https://docs.claude.com/en/docs/about-claude/models/overview).
2929

30-
You can use Anthropic models with [`AnthropicGenerator`](https://docs.haystack.deepset.ai/docs/anthropicgenerator) and [`AnthropicChatGenerator`](https://docs.haystack.deepset.ai/docs/anthropicchatgenerator).
30+
You can use Anthropic models with [`AnthropicChatGenerator`](https://docs.haystack.deepset.ai/docs/anthropicchatgenerator).
3131

3232
## Installation
3333

@@ -37,7 +37,6 @@ pip install anthropic-haystack
3737

3838
## Usage
3939

40-
Based on your use case, you can choose between [`AnthropicGenerator`](https://docs.haystack.deepset.ai/docs/anthropicgenerator) or [`AnthropicChatGenerator`](https://docs.haystack.deepset.ai/docs/anthropicchatgenerator) to work with Anthropic models. To learn more about the difference, visit the [Generators vs Chat Generators](https://docs.haystack.deepset.ai/docs/generators-vs-chat-generators) guide.
4140
Before using, make sure to set the `ANTHROPIC_API_KEY` environment variable.
4241

4342
### Using `AnthropicChatGenerator`
@@ -94,20 +93,3 @@ rag_pipeline.run(
9493
}
9594
)
9695
```
97-
98-
### Using `AnthropicGenerator`
99-
100-
Below is an example of using `AnthropicGenerator`:
101-
102-
```python
103-
from haystack_integrations.components.generators.anthropic import AnthropicGenerator
104-
105-
client = AnthropicGenerator()
106-
response = client.run("What's Natural Language Processing? Be brief.")
107-
print(response)
108-
109-
>>{'replies': ['Natural language processing (NLP) is a branch of artificial intelligence focused on enabling
110-
>>computers to understand, interpret, and manipulate human language. The goal of NLP is to read, decipher,
111-
>> understand, and make sense of the human languages in a manner that is valuable.'], 'meta': {'model':
112-
>> 'claude-2.1', 'index': 0, 'finish_reason': 'end_turn', 'usage': {'input_tokens': 18, 'output_tokens': 58}}}
113-
```

‎integrations/apify.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ from dotenv import load_dotenv
141141
from haystack import Document, Pipeline
142142
from haystack.components.builders import PromptBuilder
143143
from haystack.components.embedders import OpenAIDocumentEmbedder, OpenAITextEmbedder
144-
from haystack.components.generators import OpenAIGenerator
144+
from haystack.components.generators.chat import OpenAIChatGenerator
145145
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
146146
from haystack.document_stores.in_memory import InMemoryDocumentStore
147147
from haystack.utils.auth import Secret
@@ -185,7 +185,7 @@ document_store = InMemoryDocumentStore()
185185
docs_embedder = OpenAIDocumentEmbedder()
186186
text_embedder = OpenAITextEmbedder()
187187
retriever = InMemoryEmbeddingRetriever(document_store)
188-
generator = OpenAIGenerator(model="gpt-3.5-turbo")
188+
generator = OpenAIChatGenerator(model="gpt-4.1-mini")
189189
190190
# Load documents from Apify
191191
print("Crawling and indexing documents...")
@@ -227,7 +227,7 @@ print("Running pipeline ... ")
227227
response = pipe.run({"embedder": {"text": question}, "prompt_builder": {"question": question}})
228228
229229
print(f"question: {question}")
230-
print(f"answer: {response['llm']['replies'][0]}")
230+
print(f"answer: {response['llm']['replies'][0].text}")
231231
232232
# Other questions
233233
examples = [
@@ -238,7 +238,7 @@ examples = [
238238
for example in examples:
239239
response = pipe.run({"embedder": {"text": example}, "prompt_builder": {"question": example}})
240240
print(f"question: {question}")
241-
print(f"answer: {response['llm']['replies'][0]}")
241+
print(f"answer: {response['llm']['replies'][0].text}")
242242
```
243243

244244

‎integrations/arize-phoenix.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Now, you can run a Haystack pipeline within the same environment, resulting in t
6868
```python
6969
from haystack import Document, Pipeline
7070
from haystack.components.builders.prompt_builder import PromptBuilder
71-
from haystack.components.generators import OpenAIGenerator
71+
from haystack.components.generators.chat import OpenAIChatGenerator
7272
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
7373
from haystack.document_stores.in_memory import InMemoryDocumentStore
7474

@@ -91,7 +91,7 @@ Answer:
9191

9292
retriever = InMemoryBM25Retriever(document_store=document_store)
9393
prompt_builder = PromptBuilder(template=prompt_template)
94-
llm = OpenAIGenerator()
94+
llm = OpenAIChatGenerator()
9595

9696
rag_pipeline = Pipeline()
9797
rag_pipeline.add_component("retriever", retriever)

‎integrations/arize.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Now, you can run a Haystack pipeline within the same environment, resulting in t
6464
```python
6565
from haystack import Document, Pipeline
6666
from haystack.components.builders.prompt_builder import PromptBuilder
67-
from haystack.components.generators import OpenAIGenerator
67+
from haystack.components.generators.chat import OpenAIChatGenerator
6868
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
6969
from haystack.document_stores.in_memory import InMemoryDocumentStore
7070

@@ -87,7 +87,7 @@ Answer:
8787

8888
retriever = InMemoryBM25Retriever(document_store=document_store)
8989
prompt_builder = PromptBuilder(template=prompt_template)
90-
llm = OpenAIGenerator()
90+
llm = OpenAIChatGenerator()
9191

9292
rag_pipeline = Pipeline()
9393
rag_pipeline.add_component("retriever", retriever)

‎integrations/assemblyai.md‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ The metadata of the transcription document contains the transcription ID and url
113113
### Summarization
114114
You can perform summarization with `AssemblyAITranscriber` by setting `"summarization": True`. When activated, `AssemblyAITranscriber` provides both a `transcription` object and a `summarization` output.
115115

116-
The example below illustrates a generative QA pipeline that seamlessly integrates `AssemblyAITranscriber` and `OpenAIGenerator`. This pipeline generates answers based on the given question and the summarized transcription:
116+
The example below illustrates a generative QA pipeline that seamlessly integrates `AssemblyAITranscriber` and `OpenAIChatGenerator`. This pipeline generates answers based on the given question and the summarized transcription:
117117

118118
```python
119119
from haystack import Pipeline
120120
from haystack.utils import Secret
121121
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
122122
from haystack.components.builders.prompt_builder import PromptBuilder
123-
from haystack.components.generators import OpenAIGenerator
123+
from haystack.components.generators.chat import OpenAIChatGenerator
124124
from assemblyai_haystack.transcriber import AssemblyAITranscriber
125125

126126
template = """
@@ -134,7 +134,7 @@ Question: {{ question }}
134134
summary_qa = Pipeline()
135135
summary_qa.add_component("transcriber", AssemblyAITranscriber(api_key=assemblyai_api_key))
136136
summary_qa.add_component("prompt_builder", PromptBuilder(template=template))
137-
summary_qa.add_component("llm", OpenAIGenerator(api_key=Secret.from_token("YOUR_OPENAI_API_KEY"), model="gpt-3.5-turbo"))
137+
summary_qa.add_component("llm", OpenAIChatGenerator(api_key=Secret.from_token("YOUR_OPENAI_API_KEY"), model="gpt-4.1-mini"))
138138
summary_qa.connect("transcriber.summarization", "prompt_builder.summary")
139139
summary_qa.connect("prompt_builder", "llm")
140140

@@ -156,7 +156,7 @@ from haystack import Pipeline
156156
from haystack.utils import Secret
157157
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
158158
from haystack.components.builders.prompt_builder import PromptBuilder
159-
from haystack.components.generators import OpenAIGenerator
159+
from haystack.components.generators.chat import OpenAIChatGenerator
160160
from assemblyai_haystack.transcriber import AssemblyAITranscriber
161161

162162
## Write utterances into InMemoryDocumentStore
@@ -178,7 +178,7 @@ Question: {{ question }}
178178
pipe = Pipeline()
179179
pipe.add_component("retriever", InMemoryBM25Retriever(document_store=document_store, top_k=3))
180180
pipe.add_component("prompt_builder", PromptBuilder(template=template))
181-
pipe.add_component("llm", OpenAIGenerator(api_key=Secret.from_token("YOUR_OPENAI_API_KEY"), model="gpt-3.5-turbo"))
181+
pipe.add_component("llm", OpenAIChatGenerator(api_key=Secret.from_token("YOUR_OPENAI_API_KEY"), model="gpt-4.1-mini"))
182182

183183
pipe.connect("retriever", "prompt_builder.documents")
184184
pipe.connect("prompt_builder", "llm")
@@ -198,11 +198,5 @@ pipe.run({
198198
Since this filtering only returns the text where person A was the speaker, it can't find any relevant results. Run the same pipeline for speaker B information to get results.
199199

200200
```shell
201-
{'llm': {'replies': ['The documents do not provide explicit information on who is more affected by wildfires.'],
202-
'meta': [{'model': 'gpt-3.5-turbo-0613',
203-
'index': 0,
204-
'finish_reason': 'stop',
205-
'usage': {'completion_tokens': 15,
206-
'prompt_tokens': 177,
207-
'total_tokens': 192}}]}}
201+
{'llm': {'replies': [ChatMessage(_role=<ChatRole.ASSISTANT: 'assistant'>, _content=[TextContent(text='The documents do not provide explicit information on who is more affected by wildfires.')], _name=None, _meta={'model': 'gpt-4.1-mini-2025-04-14', 'index': 0, 'finish_reason': 'stop', 'usage': {'completion_tokens': 15, 'prompt_tokens': 177, 'total_tokens': 192}})]}}
208202
```

‎integrations/azure.md‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ To work with Azure components, you will need an Azure OpenAI API key, an [Azure
4343

4444
### Components
4545

46-
- [AzureOpenAIGenerator](https://docs.haystack.deepset.ai/docs/azureopenaigenerator)
4746
- [AzureOpenAIChatGenerator](https://docs.haystack.deepset.ai/docs/azureopenaichatgenerator)
4847
- [AzureOpenAITextEmbedder](https://docs.haystack.deepset.ai/docs/azureopenaitextembedder)
4948
- [AzureOpenAIDocumentEmbedder](https://docs.haystack.deepset.ai/docs/azureopenaidocumentembedder)
@@ -83,17 +82,17 @@ indexing_pipeline.run({"embedder": {"documents": documents}})
8382

8483
### Generative Models (LLMs)
8584

86-
You can leverage Azure OpenAI models through two components: [AzureOpenAIGenerator](https://docs.haystack.deepset.ai/docs/azureopenaigenerator) and [AzureOpenAIChatGenerator](https://docs.haystack.deepset.ai/docs/azureopenaichatgenerator).
85+
You can leverage Azure OpenAI models through the [AzureOpenAIChatGenerator](https://docs.haystack.deepset.ai/docs/azureopenaichatgenerator) component.
8786

88-
To use OpenAI models deployed through Azure services for text generation, initialize a `AzureOpenAIGenerator` with `azure_deployment` and `azure_endpoint`. You can then use the `AzureOpenAIGenerator` instance in a pipeline after the `PromptBuilder`.
87+
To use OpenAI models deployed through Azure services for text generation, initialize an `AzureOpenAIChatGenerator` with `azure_deployment` and `azure_endpoint`. You can then use the `AzureOpenAIChatGenerator` instance in a pipeline after the `PromptBuilder`.
8988

90-
Below is the example of generative questions answering pipeline using RAG with `PromptBuilder` and `AzureOpenAIGenerator`:
89+
Below is the example of generative questions answering pipeline using RAG with `PromptBuilder` and `AzureOpenAIChatGenerator`:
9190

9291
```python
9392
from haystack import Pipeline
9493
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
9594
from haystack.components.builders.prompt_builder import PromptBuilder
96-
from haystack.components.generators import AzureOpenAIGenerator
95+
from haystack.components.generators.chat import AzureOpenAIChatGenerator
9796

9897
os.environ["AZURE_OPENAI_API_KEY"] = "Your Azure OpenAI API key"
9998
os.environ["AZURE_OPENAI_AD_TOKEN"] = "Your Azure Active Directory Token"
@@ -112,7 +111,7 @@ pipe = Pipeline()
112111

113112
pipe.add_component("retriever", InMemoryBM25Retriever(document_store=document_store))
114113
pipe.add_component("prompt_builder", PromptBuilder(template=template))
115-
pipe.add_component("llm", AzureOpenAIGenerator(azure_endpoint="https://example-resource.azure.openai.com/", azure_deployment="gpt-35-turbo"))
114+
pipe.add_component("llm", AzureOpenAIChatGenerator(azure_endpoint="https://example-resource.azure.openai.com/", azure_deployment="gpt-4.1-mini"))
116115
pipe.connect("retriever", "prompt_builder.documents")
117116
pipe.connect("prompt_builder", "llm")
118117

‎integrations/cerebras.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ from haystack.utils import Secret
4141
from haystack.components.fetchers import LinkContentFetcher
4242
from haystack.components.converters import HTMLToDocument
4343
from haystack.components.builders import PromptBuilder
44-
from haystack.components.generators import OpenAIGenerator
44+
from haystack.components.generators.chat import OpenAIChatGenerator
4545

4646
fetcher = LinkContentFetcher()
4747
converter = HTMLToDocument()
@@ -54,7 +54,7 @@ Answer the given question: {{query}}
5454
Answer:
5555
"""
5656
prompt_builder = PromptBuilder(template=prompt_template)
57-
llm = OpenAIGenerator(
57+
llm = OpenAIChatGenerator(
5858
api_key=Secret.from_env_var("CEREBRAS_API_KEY"),
5959
api_base_url="https://api.cerebras.ai/v1",
6060
model="llama3.1-8b"
@@ -67,12 +67,12 @@ pipeline.add_component("llm", llm)
6767

6868
pipeline.connect("fetcher.streams", "converter.sources")
6969
pipeline.connect("converter.documents", "prompt.documents")
70-
pipeline.connect("prompt.prompt", "llm.prompt")
70+
pipeline.connect("prompt.prompt", "llm.messages")
7171

7272
result = pipeline.run({"fetcher": {"urls": ["https://cerebras.ai/inference"]},
7373
"prompt": {"query": "Why should I use Cerebras for serving LLMs?"}})
7474

75-
print(result["llm"]["replies"][0])
75+
print(result["llm"]["replies"][0].text)
7676
```
7777

7878
### Using `ChatGenerator`

0 commit comments

Comments
 (0)