Skip to content
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: Support ChatZhipuAI with agent tools call #21404

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

migo-robben
Copy link

Description: This update fixed the problem that the ChatZhipuAI module can't call tools, now it can support tool calls in the agent.

from langchain_community.chat_models import ChatZhipuAI
# from ... import ...

# Add, Divide is your tools
tools = [Add(), Divide()]
openai_tools_agent_prompt = hub.pull("hwchase17/openai-tools-agent")

chat = ChatZhipuAI(model="glm-3-turbo")
agent = create_openai_tools_agent(chat, tools, openai_tools_agent_prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = agent_executor.invoke(
    {
        "input": "What is the result of adding 12.5 to the division of 3 by 15?"
    }
)

Copy link

vercel bot commented May 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2024 1:44am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Ɑ: agent Related to agents module 🤖:improvement Medium size change to existing code to handle new use-cases labels May 8, 2024
@@ -133,19 +151,22 @@ def _convert_delta_to_message_chunk(
role = dct.get("role")
content = dct.get("content", "")
additional_kwargs = {}
tool_calls = dct.get("tool_call", None)
tool_calls = dct.get("tool_calls", None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was dct.get("tool_call", None) a bug earlier?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when the return is a tool call, zhipuai use "tool_calls" as the key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: agent Related to agents module 🤖:improvement Medium size change to existing code to handle new use-cases size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants