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
The latest code runs into invalid message format when using OpenAIServerModel
Code to reproduce the error
from smolagents import CodeAgent, DuckDuckGoSearchTool,OpenAIServerModel
model = OpenAIServerModel(
model_id="<...>",
api_base="<...>",
api_key="<...>"
)
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
Error logs (if any)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Error in generating model output:
Error code: 400 - {'error': {'code': 'invalid_argument', 'message': 'Message index[1] content should be string', 'type': 'invalid_request_error'}}
[Step 0: Duration 0.26 seconds]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Error in generating model output:
Error code: 400 - {'error': {'code': 'invalid_argument', 'message': 'Message index[1] content should be string', 'type': 'invalid_request_error'}}
Expected behavior
A clear and concise description of what you expected to happen.
Packages version: main branch
Additional context
Pretty sure this is due to OpenAI SDK uses flat message format without images but nested message format with image. The current code always use nested message, which results in this bug.
without image
client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-4o",
)
fromsmolagentsimportCodeAgent, DuckDuckGoSearchTool,OpenAIServerModelmodel=OpenAIServerModel(
model_id="gpt-4",
)
agent=CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
Describe the bug
The latest code runs into invalid message format when using
OpenAIServerModel
Code to reproduce the error
Error logs (if any)
Expected behavior
A clear and concise description of what you expected to happen.
Packages version:
main
branchAdditional context
Pretty sure this is due to OpenAI SDK uses flat message format without images but nested message format with image. The current code always use nested message, which results in this bug.
without image
with image
The text was updated successfully, but these errors were encountered: