Closed sharrajesh closed 2 months ago
I got it working by using "langchain-core==0.2.20"
thank you; your suggestion works; it seems something broke in langchain-core 0.2.21
@sharrajesh could you include a minimal reproducible example. We won't be able to help otherwise. You don't need to include any proprietary code.
Also please include the output of: python -m langchain_core.sys_info
This issue will likely have been fixed in the next release of langchain-core (can't tell for sure since there's no reproduction code)
I will give a try and update here.
Confirmed problem has been fixed by latest langchain-core. Thank you langchain team!
Checked other resources
Example Code
my code is proprietary
Error Message and Stack Trace (if applicable)
Traceback (most recent call last): File "/home/username/.pycharm_helpers/pydev/pydevd.py", line 1551, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/username/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/username/code/ai/myproject/examples/llm_rule_translation_and_creation.py", line 20, in
sigma_agent_executor = create_sigma_agent(sigma_vectorstore=sigma_llm.sigmadb)
File "/home/username/code/ai/myproject/myproject/llm/toolkits/base.py", line 63, in create_sigma_agent
llm_with_tools = agent_llm.bind(functions=[convert_to_openai_function(t) for t in tools])
File "/home/username/code/ai/myproject/myproject/llm/toolkits/base.py", line 63, in
llm_with_tools = agent_llm.bind(functions=[convert_to_openai_function(t) for t in tools])
File "/home/username/.cache/pypoetry/virtualenvs/myproject-ItWCGl7B-py3.10/lib/python3.10/site-packages/langchain_core/utils/function_calling.py", line 278, in convert_to_openai_function
return cast(Dict, format_tool_to_openai_function(function))
File "/home/username/.cache/pypoetry/virtualenvs/myproject-ItWCGl7B-py3.10/lib/python3.10/site-packages/langchain_core/_api/deprecation.py", line 168, in warning_emitting_wrapper
return wrapped(*args, **kwargs)
File "/home/username/.cache/pypoetry/virtualenvs/myproject-ItWCGl7B-py3.10/lib/python3.10/site-packages/langchain_core/utils/function_calling.py", line 199, in format_tool_to_openai_function
if tool.tool_call_schema:
File "/home/username/.cache/pypoetry/virtualenvs/myproject-ItWCGl7B-py3.10/lib/python3.10/site-packages/langchain_core/tools.py", line 428, in tool_call_schema
return _create_subset_model(
File "/home/username/.cache/pypoetry/virtualenvs/myproject-ItWCGl7B-py3.10/lib/python3.10/site-packages/langchain_core/tools.py", line 129, in _create_subset_model
if field.required and not field.allow_none
AttributeError: 'FieldInfo' object has no attribute 'required'. Did you mean: 'is_required'?
Description
I started seeing an AttributeError after upgrading to Pydantic v2.0 while using the latest version of LangChain. The error message is:
csharp Copy code AttributeError: 'FieldInfo' object has no attribute 'required'. Did you mean: 'is_required'? This issue seems related to the recent Pydantic upgrade. See the trace for more information. Downgrading Pydantic resolves the issue.
System Info
LangChain Version: Latest Pydantic Version: 2.20.1 Python Version: 3.10.12 Operating System: Windows with WSL Ubuntu poetry