-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Add Chat Generator supporting OpenAI Responses API #9808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0ccca9
8363ae6
eba8123
18ce0e0
ba14b18
eeec152
64052f7
ef4d0a7
149a47e
f3b41f2
50d5feb
d1bea24
f2ba387
830d086
2c866f9
228a21b
1b0ac65
96e9343
515474a
9d8aa42
b1d6e80
9e414a9
00e6013
419ec36
2a7f342
76db039
0bab968
8c8e031
9107989
fe07300
c8083ba
40406aa
88760c0
d8949fc
150b94a
ed299f3
c973c8d
a0bb425
412c26d
41164ec
eb04021
d5c1717
0ba664e
90f8da5
85064ee
c78e972
6cae697
ac2cc2f
59f2064
b8d4f02
334db3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| --- | ||
| features: | ||
Amnah199 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - | | ||
| Added the OpenAIResponsesChatGenerator, a new component that integrates OpenAI's Responses API into Haystack. | ||
| This unlocks several advanced capabilities from the Responses API: | ||
| - Allowing retrieval of concise summaries of the model's reasoning process. | ||
| - Allowing the use of native OpenAI or MCP tool formats, along with Haystack Tool objects and Toolset instances. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What else do we support and integrate well from our ecosystem into Responses?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Structured outputs could be one. |
||
|
|
||
| Example with reasoning and web search tool: | ||
| ```python | ||
| from haystack.components.generators.chat import OpenAIResponsesChatGenerator | ||
| from haystack.dataclasses import ChatMessage | ||
|
|
||
| chat_generator = OpenAIResponsesChatGenerator( | ||
| model="o3-mini", | ||
| generation_kwargs={ | ||
| {"summary": "auto", "effort": "low"} | ||
| }, | ||
| tools=[{"type": "web_search"}] | ||
| ) | ||
|
|
||
| response = chat_generator.run( | ||
| messages=[ | ||
| ChatMessage.from_user("What's a positive news story from today?") | ||
| ] | ||
| ) | ||
| print(response["replies"][0].text) | ||
| ``` | ||
|
|
||
| Example with structured output: | ||
| ```python | ||
| from pydantic import BaseModel | ||
| from haystack.components.generators.chat import OpenAIResponsesChatGenerator | ||
| from haystack.dataclasses import ChatMessage | ||
|
|
||
| class WeatherInfo(BaseModel): | ||
| location: str | ||
| temperature: float | ||
| conditions: str | ||
|
|
||
| chat_generator = OpenAIResponsesChatGenerator( | ||
| model="gpt-5-mini", | ||
| generation_kwargs={"text_format": WeatherInfo} | ||
| ) | ||
|
|
||
| response = chat_generator.run( | ||
| messages=[ChatMessage.from_user("What's the weather in Paris?")] | ||
| ) | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.