Loading Qwen-2.5 32B model using VLLM and creating an agent with integrated tools. #29117
SalmonSung
announced in
Ask Dosu (Archived)
Replies: 1 comment 18 replies
-
Hey @ISaySalmonYouSayYes! I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. Let's tackle this together! To integrate tools with agents in LangChain using VLLM, you can implement the def bind_tools(
self,
tools: typing.Sequence[typing.Union[dict[str, typing.Any], type, typing.Callable, BaseTool]],
*,
tool_choice: typing.Optional[typing.Union[dict, str, typing.Literal['auto', 'none'], bool]] = None,
**kwargs: typing.Any,
) -> Runnable[LanguageModelInput, BaseMessage]:
formatted_tools = [convert_to_openai_tool(tool) for tool in tools]
if tool_choice is not None and tool_choice:
if len(formatted_tools) != 1:
raise ValueError(
'When specifying `tool_choice`, you must provide exactly one '
f'tool. Received {len(formatted_tools)} tools.'
)
if isinstance(tool_choice, str):
if tool_choice not in ('auto', 'none'):
tool_choice = {
'type': 'function',
'function': {'name': tool_choice},
}
elif isinstance(tool_choice, bool):
tool_choice = formatted_tools[0]
elif isinstance(tool_choice, dict):
if formatted_tools[0]['function']['name'] != tool_choice['function']['name']:
raise ValueError(
f'Tool choice {tool_choice} was specified, but the only '
f'provided tool was {formatted_tools[0]["function"]["name"]}.'
)
else:
raise ValueError(
f'Unrecognized tool_choice type. Expected str, bool or dict. '
f'Received: {tool_choice}'
)
kwargs['tool_choice'] = tool_choice
return super().bind(tools=formatted_tools, **kwargs) This implementation allows ChatMLX to work with react agents by formatting the tools and handling the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
18 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently trying to load the Qwen model using VLLM and create an agent with integrated tools.
What I've tried so far:
create_react_agent: This resulted in an error, stating that the 'VLLM' object has no attribute 'bind_tools.'
Is there an alternative method to achieve similar functionality? Unfortunately, I need to use VLLM for its speed and efficiency.
Beta Was this translation helpful? Give feedback.
All reactions