Chat completion with Qwen2.5-instruct model #4522
Replies: 2 comments 1 reply
-
Hi Gary Tang, |
Beta Was this translation helpful? Give feedback.
-
@GaryTang32 thanks for bring this up. This might have cleared both issues in #5869 and #6036 about tool calling with Qwen models. This seems a very minor difference. I don't have access to Qwen cloud hosted models. The local Qwen 2.5 models when deployed using vllm or ollama works just fine using OpenAI client. I think at this point it looks like something that may change again soon, I am not sure if that's something we want to include in our library yet -- the client will become a bunch of hacks put together. Instead of making the change directly in the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
Problem:
I developed a SelectorGroupChat cluster to do some task with tools call.
When I uses GPT4o-mini, it works and able to accomplish the task with tools call.
but when i switch the model into Qwen2.5-instruct model, the cluster failed to use any tools call.
Solution:
After investigation, the problem is Qwen model need a different argument structure when calling chat completion with oai.chat.completions.create. Qwen model's tool_use argument structure is different from GPT4o-mini.
GPT4o-mini:
Qwen2.5-instruct:
Qwen model tools_use argument is passed with "extra_body", while GPT is "tools".
And under the "_openai_client.py" in the AutoGen 0.4Dev8. It hardcoded the oai.chat.completion.create using "tools" argument for tools use passing.
therefore when using Qwen model, it wont raise error or exception, but the model unable to decode the tools under "tools" argument, leading unable to use any tools in the cluster.
To resolve the case, changing the oat.chat.completions.create() argument it works.
Update autogen_ext/models/_openai/_openai_client.py
line 460 from:
to:
this resolve the tools_use argument passing.
Tested this approach with both GPT4o-mini and Qwen2.5-instruct.
Both models able to use tools call after changes.
Is it able to include this change in the next updates? Or is there any method to adopt Qwen model tools call?
Thanks so much.
Best regards,
Gary Tang
Beta Was this translation helpful? Give feedback.
All reactions