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
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangChain rather than my code.
The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
@tool
def get_schema_tool(args: str):
"""Can be used to get connections and objects associated with the applications and input is a python list
of applications e.g. ["app1","app2"]"""
app_list = ast.literal_eval(args)
return app_list
File "C:\Users\ysaini\OneDrive - Informatica\Desktop\ApiGenie\ConversationMemory\cai_copilot.py", line 103, in
output = process_input(u_input, conv_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\OneDrive - Informatica\Desktop\ApiGenie\ConversationMemory\cai_copilot.py", line 87, in process_input
out = copilot_agent.invoke({"input": user_input},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 3022, in invoke
input = context.run(step.invoke, input, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 4706, in invoke
return self._call_with_config(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 1923, in _call_with_config
context.run(
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\config.py", line 396, in call_func_with_variable_args
return func(input, **kwargs) # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 4572, in _invoke
output = output.invoke(
^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\chains\base.py", line 170, in invoke
raise e
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\chains\base.py", line 160, in invoke
self._call(inputs, run_manager=run_manager)
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1629, in _call
next_step_output = self._take_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1337, in _take_next_step
for a in self._iter_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1420, in _iter_next_step
yield self._perform_agent_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1442, in _perform_agent_action
observation = tool.run(
^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 688, in run
raise error_to_raise
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 651, in run
tool_args, tool_kwargs = self._to_args_and_kwargs(tool_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 574, in _to_args_and_kwargs
tool_input = self._parse_input(tool_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 509, in parse_input
input_args.model_validate({key: tool_input})
File "C:\Users\ysaini\venv\Lib\site-packages\pydantic\main.py", line 596, in model_validate
return cls.pydantic_validator.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for get_schema_tool
v__args
Input should be a valid list [type=list_type, input_value='["Salesforce", "ServiceNow"]', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/list_type
Description
I have a tool which expects a string. This string is a string representation of a python list of strings. In the tool I do literal_eval to convert it into a python list.
But I get this error:
Input should be a valid list [type=list_type, input_value='["Salesforce", "ServiceNow"]', input_type=str]
Why is it expecting list when I have clearly defined the args as string.
System Info
System Information
OS: Windows
OS Version: 10.0.19045
Python Version: 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)]
aiohttp: 3.10.6
async-timeout: Installed. No version info available.
httpx: 0.27.2
jsonpatch: 1.33
numpy: 1.26.4
orjson: 3.10.7
packaging: 24.1
pydantic: 2.9.2
PyYAML: 6.0.2
requests: 2.32.3
SQLAlchemy: 2.0.35
tenacity: 8.5.0
typing-extensions: 4.12.2
The text was updated successfully, but these errors were encountered:
dosubotbot
added
Ɑ: core
Related to langchain-core
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
labels
Sep 25, 2024
class PydanticArgs(BaseModel):
args: str
@tool(args_schema=PydanticArgs)
def get_schema_tool(args: str):
"""Can be used to get connections and objects associated with the applications and input is a python list
of applications e.g. ["app1","app2"]"""
app_list = ast.literal_eval(args)
return app_list
input = '["app1", "app2"]'
get_schema_tool(input)
Checked other resources
Example Code
@tool
def get_schema_tool(args: str):
"""Can be used to get connections and objects associated with the applications and input is a python list
of applications e.g. ["app1","app2"]"""
app_list = ast.literal_eval(args)
return app_list
agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor.from_agent_and_tools(
agent=agent,
tools=tools,
verbose=True,
handle_parsing_errors=True,
max_iterations=4000,
max_execution_time=60000,
return_intermediate_steps=True
)
agent_executor.agent.stream_runnable = False
agent_runnable = RunnableWithMessageHistory(
agent_executor,
lambda session_id: memory,
input_messages_key="input",
history_messages_key="chat_history",
)
agentrunnable.invoke({"input": user_input})
Error Message and Stack Trace (if applicable)
File "C:\Users\ysaini\OneDrive - Informatica\Desktop\ApiGenie\ConversationMemory\cai_copilot.py", line 103, in
output = process_input(u_input, conv_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\OneDrive - Informatica\Desktop\ApiGenie\ConversationMemory\cai_copilot.py", line 87, in process_input
out = copilot_agent.invoke({"input": user_input},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 3022, in invoke
input = context.run(step.invoke, input, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 4706, in invoke
return self._call_with_config(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 1923, in _call_with_config
context.run(
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\config.py", line 396, in call_func_with_variable_args
return func(input, **kwargs) # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 4572, in _invoke
output = output.invoke(
^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\runnables\base.py", line 5343, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\chains\base.py", line 170, in invoke
raise e
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\chains\base.py", line 160, in invoke
self._call(inputs, run_manager=run_manager)
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1629, in _call
next_step_output = self._take_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1337, in _take_next_step
for a in self._iter_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1420, in _iter_next_step
yield self._perform_agent_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain\agents\agent.py", line 1442, in _perform_agent_action
observation = tool.run(
^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 688, in run
raise error_to_raise
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 651, in run
tool_args, tool_kwargs = self._to_args_and_kwargs(tool_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 574, in _to_args_and_kwargs
tool_input = self._parse_input(tool_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ysaini\venv\Lib\site-packages\langchain_core\tools\base.py", line 509, in parse_input
input_args.model_validate({key: tool_input})
File "C:\Users\ysaini\venv\Lib\site-packages\pydantic\main.py", line 596, in model_validate
return cls.pydantic_validator.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for get_schema_tool
v__args
Input should be a valid list [type=list_type, input_value='["Salesforce", "ServiceNow"]', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/list_type
Description
I have a tool which expects a string. This string is a string representation of a python list of strings. In the tool I do literal_eval to convert it into a python list.
But I get this error:
Input should be a valid list [type=list_type, input_value='["Salesforce", "ServiceNow"]', input_type=str]
Why is it expecting list when I have clearly defined the args as string.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: