-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
add support for some models whose tool call arguments is not a json object #5257
Comments
Hello @htao7 ! Can you post your code including the model client? What model client did you use? It seems strange because a model client shouldn't be returning the arguments as a dictionary. It looks like a bug in the model client. |
I tested using deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B from HF inference API (haven't tested with DeepSeek API directly since it is under maintenance). I believe it is openAI compatible?
|
Looks like Hugging Face API is not strictly openai-compatible. Add a PR #5260 to fix this. |
What feature would you like to be added?
Some of the models' tool call arguments does not return a json object but a dictionary.
For example, AssistantAgent using DeepSeek-R1-Distill-Qwen-1.5B on HF inference api, inner_messages:
[ToolCallRequestEvent(source='Weather_Agent', models_usage=RequestUsage(prompt_tokens=173, completion_tokens=19), content=[FunctionCall(id='0', arguments={'location': 'Hangzhou'}, name='get_weather')], type='ToolCallRequestEvent'), ToolCallExecutionEvent(source='Weather_Agent', models_usage=None, content=[FunctionExecutionResult(content='Error: the JSON object must be str, bytes or bytearray, not dict', call_id='0')], type='ToolCallExecutionEvent')]
As a reference, gpt-4o-mini inner_messages:
[ToolCallRequestEvent(source='Weather_Agent', models_usage=RequestUsage(prompt_tokens=69, completion_tokens=16), content=[FunctionCall(id='call_xxx', arguments='{"location":"Hangzhou"}', name='get_weather')], type='ToolCallRequestEvent'), ToolCallExecutionEvent(source='Weather_Agent', models_usage=None, content=[FunctionExecutionResult(content='Hangzhou, nice!', call_id='call_6F0V1emkKJCleuTmo0PKpzge')], type='ToolCallExecutionEvent')]
Add support for dictionary type argument can allow the usage of these models. A temporary fix (for dict only) could be done at autogen_agentchat/agents/_assistant_agent.py:
will have inner_messages:
[ToolCallRequestEvent(source='Weather_Agent', models_usage=RequestUsage(prompt_tokens=173, completion_tokens=19), content=[FunctionCall(id='0', arguments={'location': 'Hangzhou'}, name='get_weather')], type='ToolCallRequestEvent'), ToolCallExecutionEvent(source='Weather_Agent', models_usage=None, content=[FunctionExecutionResult(content='Hangzhou, nice!', call_id='0')], type='ToolCallExecutionEvent')]
Why is this needed?
support for some models whose tool call is not a json object, e.g., DeepSeek on HF
The text was updated successfully, but these errors were encountered: