### Checked other resources
- [X] I added a very descriptive title to this is…sue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangChain rather than my code.
### Example Code
```python
from langchain_core.messages import HumanMessage
from langgraph.graph import END, MessageGraph
from langchain_community.llms import HuggingFaceHub
repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
model = HuggingFaceHub(
repo_id=repo_id,
huggingfacehub_api_token=HUGGINGFACEHUB_API_TOKEN
)
# Define the graph
graph = MessageGraph()
graph.add_node("oracle", model)
graph.add_edge("oracle", END)
graph.set_entry_point("oracle")
runnable = graph.compile()
# Calling `.invoke()` or `.stream()` fails
runnable.invoke(
HumanMessage("What is 1 + 1?")
)
```
### Error Message and Stack Trace (if applicable)
```
{
"name": "AttributeError",
"message": "'str' object has no attribute 'id'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[127], line 1
----> 1 runnable.invoke(
2 HumanMessage(\"What is 1 + 1?\")
3 )
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langgraph/pregel/__init__.py:838, in Pregel.invoke(self, input, config, output_keys, input_keys, interrupt_before_nodes, interrupt_after_nodes, debug, **kwargs)
825 def invoke(
826 self,
827 input: Union[dict[str, Any], Any],
(...)
835 **kwargs: Any,
836 ) -> Union[dict[str, Any], Any]:
837 latest: Union[dict[str, Any], Any] = None
--> 838 for chunk in self.stream(
839 input,
840 config,
841 output_keys=output_keys if output_keys is not None else self.output,
842 input_keys=input_keys,
843 interrupt_before_nodes=interrupt_before_nodes,
844 interrupt_after_nodes=interrupt_after_nodes,
845 debug=debug,
846 **kwargs,
847 ):
848 latest = chunk
849 return latest
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langgraph/pregel/__init__.py:886, in Pregel.transform(self, input, config, output_keys, input_keys, interrupt_before_nodes, interrupt_after_nodes, debug, **kwargs)
874 def transform(
875 self,
876 input: Iterator[Union[dict[str, Any], Any]],
(...)
884 **kwargs: Any,
885 ) -> Iterator[Union[dict[str, Any], Any]]:
--> 886 for chunk in self._transform_stream_with_config(
887 input,
888 self._transform,
889 config,
890 output_keys=output_keys,
891 input_keys=input_keys,
892 interrupt_before_nodes=interrupt_before_nodes,
893 interrupt_after_nodes=interrupt_after_nodes,
894 debug=debug,
895 **kwargs,
896 ):
897 yield chunk
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langchain_core/runnables/base.py:1743, in Runnable._transform_stream_with_config(self, input, transformer, config, run_type, **kwargs)
1741 try:
1742 while True:
-> 1743 chunk: Output = context.run(next, iterator) # type: ignore
1744 yield chunk
1745 if final_output_supported:
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langgraph/pregel/__init__.py:575, in Pregel._transform(self, input, run_manager, config, **kwargs)
572 _panic_or_proceed(done, inflight, step)
574 # apply writes to channels
--> 575 _apply_writes(
576 checkpoint, channels, pending_writes, config, step + 1
577 )
579 if debug:
580 print_checkpoint(step, channels)
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langgraph/pregel/__init__.py:1062, in _apply_writes(checkpoint, channels, pending_writes, config, for_step)
1060 if chan in channels:
1061 try:
-> 1062 channels[chan].update(vals)
1063 except InvalidUpdateError as e:
1064 raise InvalidUpdateError(
1065 f\"Invalid update for channel {chan}: {e}\"
1066 ) from e
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langgraph/channels/binop.py:58, in BinaryOperatorAggregate.update(self, values)
55 values = values[1:]
57 for value in values:
---> 58 self.value = self.operator(self.value, value)
File /mnt/c/Users/alejandro.gonzalez/dev/sandbox/erdbot/.venv/lib/python3.10/site-packages/langgraph/graph/message.py:26, in add_messages(left, right)
24 m.id = str(uuid.uuid4())
25 for m in right:
---> 26 if m.id is None:
27 m.id = str(uuid.uuid4())
28 # merge
AttributeError: 'str' object has no attribute 'id'"
}
```
### Description
I'm trying to use langgraph with the Hugging Face Inference API free tier. I'm following the [simple example](https://python.langchain.com/docs/langgraph#quick-start) from the langgraph docs but using a HuggingFaceHub model instead of OpenAI, as documented [here](https://python.langchain.com/docs/integrations/chat/huggingface#huggingfacehub).
I'm expecting the LLM to generate a response to the query but instead it's showing this error. I can use this same model with other LangChain components without issue, just not with LangGraph.
### System Info
System Information
------------------
> OS: Linux
> OS Version: #1 SMP Thu Jan 11 04:09:03 UTC 2024
> Python Version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Package Information
-------------------
> langchain_core: 0.1.33
> langchain: 0.1.13
> langchain_community: 0.0.29
> langsmith: 0.1.31
> langchain_text_splitters: 0.0.1
> langgraph: 0.0.30
> huggingface-hub==0.22.1
Packages not installed (Not Necessarily a Problem)
--------------------------------------------------
The following packages were not found:
> langserve