-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix #980 Chat Completions: fails with function name for tool_choice parameter w/ streaming enabled #1206
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
Conversation
…arameter w/ streaming enabled
responses_tool_choice = OpenAIResponsesConverter.convert_tool_choice( | ||
model_settings.tool_choice | ||
) | ||
if responses_tool_choice is None or responses_tool_choice == NOT_GIVEN: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The essential changes here are 1) use Converter.convert_tool_choice
2) cover responses_tool_choice is None
pattern. Added more detailed comments about why it's necessary but happy to adjust the style if necessary
Hello, following up on this PR. Do we have an ETA to get it merged? |
@rm-openai Can you review this before next release? I think this should be safe enough to merge. |
…oice parameter w/ streaming enabled (openai#1206) This pull request resolves openai#980 simple code snippet to do tests: ```python import asyncio from openai.types.responses import ResponseTextDeltaEvent from agents import Agent, ModelSettings, Runner, function_tool, set_default_openai_api set_default_openai_api("chat_completions") @function_tool def say_hello(): print("Hello, world!") return "Hello, world!" async def main(): agent = Agent( name="Joker", instructions="You are a helpful assistant.", model_settings=ModelSettings(tool_choice="say_hello"), tools=[say_hello], ) result = Runner.run_streamed(agent, input="Please tell me 5 jokes.") async for event in result.stream_events(): if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent): print(event.data.delta, end="", flush=True) if __name__ == "__main__": asyncio.run(main()) ```
This pull request resolves #980
simple code snippet to do tests: