You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromlangchainimporthubfromlangchain.agentsimportAgentExecutor, create_tool_calling_agentfromlangchain_core.toolsimporttoolmodel=# A mistral modelprompt=ChatPromptTemplate.from_messages(
[
("system", "You are a helpful assistant"),
("placeholder", "{chat_history}"),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
]
)
@tooldefmultiply(first_int: int, second_int: int) ->int:
"""Multiply two integers together."""returnfirst_int*second_int@tooldefadd(first_int: int, second_int: int) ->int:
"Add two integers."returnfirst_int+second_int@tooldefexponentiate(base: int, exponent: int) ->int:
"Exponentiate the base to the exponent power."returnbase**exponenttools= [multiply, add, exponentiate]
# Construct the tool calling agentagent=create_tool_calling_agent(model,tools, prompt)
# Create an agent executor by passing in the agent and toolsagent_executor=AgentExecutor(agent=agent, tools=tools, verbose=True)
result=agent_executor.invoke(
{
"input": "Take 3 to the fifth power and multiply that by the sum of twelve and three, then square the whole result"
}
)
Error Message and Stack Trace (if applicable)
TypeError: Object of type StructuredTool is not JSON serializable
If I run the code as it is, it generates the error that "Object of type StructuredTool is not JSON serializable".
If I create the agent with empty tools list (i.e., tools=[]) it generates the response. However, it is not supposed to be the right way of creating agents, as far as I understand. Besides the answer with mistral7b model is very inaccurate. Even in the example provided in the link above, the answer seems to be different and wrong when checking the langSmith run.
System Info
langchain-core==0.1.52
langchain==0.1.16
The text was updated successfully, but these errors were encountered:
dosubotbot
added
Ɑ: agent
Related to agents module
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
labels
Jul 29, 2024
hm im not able to recreate. could you post the full stack trace and share how you're instantiating the model? could you also try bumping to langchain and langchain-core >=0.2?
Checked other resources
Example Code
The code is picked up from LangChain documentations
https://python.langchain.com/v0.2/docs/how_to/tools_chain/
Error Message and Stack Trace (if applicable)
TypeError: Object of type StructuredTool is not JSON serializable
Description
I am trying to run the sample code in https://python.langchain.com/v0.2/docs/how_to/tools_chain/ to call an agent equipped with tools. I see two problems:
System Info
langchain-core==0.1.52
langchain==0.1.16
The text was updated successfully, but these errors were encountered: