langgraph-tutorial.ipynb: AttributeError: 'tuple' object has no attribute 'invoke' i need help
Title:
AttributeError: 'tuple' object has no attribute 'invoke' when using OpenRouter with LangChain on Colab
Issue Description:
I encountered the following error when running my LangChain app in Google Colab:
AttributeError: 'tuple' object has no attribute 'invoke'
The only change I've made to the original code is replacing the LLM with an OpenRouter model:
llm = ChatOpenAI(
model="openai/gpt-4o-mini",
openai_api_base="https://openrouter.ai/api/v1",
temperature=0
)
The traceback points specifically to the invocation of the LLM:
classification = llm.invoke([message]).content.strip()
Full error traceback:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-65-872f2bc002f1> in <cell line: 0>()
5
6 state_input = {"text": sample_text}
----> 7 result = app.invoke(state_input)
8
9 print("Classification:", result["classification"])
6 frames
<ipython-input-62-2b776fbd1895> in classification_node(state)
6 )
7 message = HumanMessage(content=prompt.format(text=state["text"]))
----> 8 classification = llm.invoke([message]).content.strip()
9 return {"classification": classification}
10
AttributeError: 'tuple' object has no attribute 'invoke'
Could anyone help identify why this is happening? Thanks!
关闭于 2025-03-09 1 条评论