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
I was using the following code to demonstrate the tool-calling feature of HuggingFace model, but i got error.
fromlangchain_huggingfaceimportChatHuggingFace, HuggingFacePipelinepipeline=HuggingFacePipeline.from_model_id(
model_id="NousResearch/Hermes-2-Pro-Llama-3-8B",
task="text-generation",
pipeline_kwargs={
"max_new_tokens": 500,
"top_k": 50,
"temperature": 0.1,
"do_sample": True,
"return_full_text": False
},
device=0
)
model=ChatHuggingFace(llm=pipeline)
frompydanticimportBaseModel, Fieldfromlangchain_core.toolsimporttoolclassGetWeather(BaseModel):
'''Get the current weather in a given location'''location: str=Field(description="The city and state,e.g. San Francisco, CA")
classGetPopulation(BaseModel):
'''Get the current population in a given location'''location: str=Field(description="The city and state, e.g. San Francisco, CA")
model_with_tools=model.bind_tools([GetWeather, GetPopulation])
model_with_tools.invoke(
"Which city is hotter today and which is bigger: LA or NY?",
)
model_with_tools.tool_calls
Error Message and Stack Trace (if applicable)
{
"name": "AttributeError",
"message": "'ChatHuggingFace' object has no attribute 'tool_calls'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 model_with_tools.tool_calls
File /dccstor/kirushikesh/.conda/testenv/lib/python3.10/site-packages/langchain_core/runnables/base.py:5704, in RunnableBinding.__getattr__(self, name)
5703 def __getattr__(self, name: str) -> Any:
-> 5704 attr = getattr(self.bound, name)
5706 if callable(attr) and (
5707 config_param := inspect.signature(attr).parameters.get(\"config\")
5708 ):
5709 if config_param.kind == inspect.Parameter.KEYWORD_ONLY:
File /dccstor/kirushikesh/.conda/testenv/lib/python3.10/site-packages/pydantic/main.py:856, in BaseModel.__getattr__(self, item)
853 return super().__getattribute__(item) # Raises AttributeError if appropriate
854 else:
855 # this is the current error
--> 856 raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'ChatHuggingFace' object has no attribute 'tool_calls'"
}
Description
Ok, i am try to use langchain library to play with the tool-calling capability of HuggingFace models. Recently, i got to know about the Hermes-LLM tool calling capability from this blog. I am a big fan of Langchain and i thought of doing the function calling with that model in Langchain. First i am not sure if its possible yet in Langchain, but when i checked this class definition i thought its possible and i tried to reproduce the same code.
The .bind_tools() is working from ChatHuggingFace, but when i tried to read the tool_calls from the response i was getting the error.
System Info
System Information
OS: Linux
OS Version: #1 SMP Thu Dec 7 03:06:13 EST 2023
Python Version: 3.10.4 (main, Mar 31 2022, 08:41:55) [GCC 7.5.0]
Checked other resources
Example Code
I was using the following code to demonstrate the tool-calling feature of HuggingFace model, but i got error.
Error Message and Stack Trace (if applicable)
Description
Ok, i am try to use langchain library to play with the tool-calling capability of HuggingFace models. Recently, i got to know about the Hermes-LLM tool calling capability from this blog. I am a big fan of Langchain and i thought of doing the function calling with that model in Langchain. First i am not sure if its possible yet in Langchain, but when i checked this class definition i thought its possible and i tried to reproduce the same code.
The .bind_tools() is working from ChatHuggingFace, but when i tried to read the tool_calls from the response i was getting the error.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: