-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
community(sparkllm): Add function call support in Sparkllm chat model. #20607
Conversation
liugddx
commented
Apr 18, 2024
- Description: Add function call support in Sparkllm chat model. Related documents https://www.xfyun.cn/doc/spark/Web.html#_2-function-call%E8%AF%B4%E6%98%8E
- @baskaryan
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we implement the bind_tools method as well
assigning to @ccurme, we should have standard tests for chat models for tool calling right? |
# If function call only, content is None not empty string | ||
if message_dict["content"] == "": | ||
message_dict["content"] = None | ||
if "tool_calls" in message.additional_kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liugddx we should read tool calls off of message.tool_calls
here, instead of (or with higher priority than) additional_kwargs.
] | ||
prompt = ChatPromptTemplate(messages=prompt_msgs) | ||
|
||
chain = prompt | chat.bind(functions=_FUNCTIONS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest implementing bind_tools
for consistency with other chat models. see example here:
langchain/libs/partners/mistralai/langchain_mistralai/chat_models.py
Lines 626 to 627 in bd4b68c
formatted_tools = [convert_to_openai_tool(tool) for tool in tools] | |
return super().bind(tools=formatted_tools, **kwargs) |