-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Assistant with gpt-4o and gpt-4o-mini may call unsupported tool 'browser' and throw exception #1574
Comments
Hi @kunerzzz I can't reproduce this, could you share a full example script? from openai import OpenAI
client = OpenAI()
assistant = client.beta.assistants.create(
name="Math Tutor",
instructions="You are a personal math tutor. Write and run code to answer math questions.",
tools=[{"type": "code_interpreter"}],
model="gpt-4o-mini",
)
with client.beta.threads.create_and_run_stream(
assistant_id=assistant.id,
model="gpt-4o-mini",
instructions="Use browser tool first to answer the user's question",
thread={"messages": [{"role": "user", "content": "Who is Tom"}]},
tool_choice="required",
) as stream:
stream.until_done() this passes with the only output being a pydantic warning
|
Hi @RobertCraigie, I just checked the version of pydantic and found that in the problematic environment, version 2.0.0 is installed. Updating pydantic seems to solve my problem. |
@RobertCraigie Sorry, there are still some issue client = OpenAI()
class EventHandler(AssistantEventHandler):
def __init__(self) -> None:
super().__init__()
@override
def on_event(self, event: AssistantStreamEvent) -> None:
if isinstance(event, ThreadRunStepCompleted):
if event.data.type == 'tool_calls':
for tool_call in event.data.step_details.tool_calls:
# type(tool_call) is <class 'dict'>
if tool_call.type == 'code_interpreter':
pass
elif tool_call.type == 'file_search':
pass
@override
def _emit_sse_event(self, event: AssistantStreamEvent) -> None:
if event.event == "thread.run.step.delta":
print(f'{type(event)} {type(event.data)} {type(event.data.delta)} {str(event.data.delta)}')
super()._emit_sse_event(event)
client = OpenAI()
assistant = client.beta.assistants.create(
name="Math Tutor",
instructions="You are a personal math tutor. Write and run code to answer math questions.",
tools=[{"type": "code_interpreter"}],
model="gpt-4o-mini",
)
with client.beta.threads.create_and_run_stream(
assistant_id=assistant.id,
model="gpt-4o-mini",
instructions="Use browser tool first to answer the user's question",
thread={"messages": [{"role": "user", "content": "Who is Tom"}]},
tool_choice="required",
event_handler=EventHandler()
) as stream:
stream.until_done() Output:
New environment: > python -m pip list | grep -E 'openai|pydantic'
openai 1.36.0
pydantic 2.8.2
pydantic_core 2.20.1
> python --version
Python 3.12.2
> uname -a
Darwin Kernel Version 23.3.0 |
Thanks for the report. Unfortunately we're unlikely to be able to prioritise fixing this soon but if you would be willing to put up a PR I'd be happy to review it. |
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
When calling the Assistant API and selecting the
gpt-4o
orgpt-4o-mini
model, the model may attempt to call an unsupportedbrowser
tool. The Python SDK does not define this type ofToolCall
, resulting in an exception being thrown.The root cause of this issue is that the API returns unexpected content. However, the SDK should be able to handle this scenario gracefully.
To Reproduce
This issue can occur under normal usage scenarios, but it is consistently reproducible with the specified configuration.
Code snippets
No response
OS
Linux
Python version
Python 3.7.4
Library version
openai v1.36.0
The text was updated successfully, but these errors were encountered: