Question related to Graphs
unhashable type: 'dict' - Help Needed
How to Manage State in LangGraph for Multiple Users?
Graph vs Stategragh
Videos
» pip install langgraph
Hi Guys,
I'm dabbling around in Langgraph and running into an issue at this point.
I am trying to make a first node in my graph that should decide if someone is just small talking or actually asking a RAG specific question. It should make that decision based on the question and memory. I've try to implement this and it works if do this only on the question, but id like to do it also based on memory.
Here is my implementation:
from typing import TypedDictfrom langgraph.graph import StateGraphfrom langgraph.graph import Graph
class AgentState(TypedDict):messages: list[str]workflow = StateGraph(AgentState)
def agent(question, memory):res = llm.invoke(f"""You are given an interaction with a user so far and the final question. Use these to decide if the user is interested in small talk or that it want to know something specifically pension related.If it's related to small talk, return "Small Talk"If it's related to pensions, return "Pension"Only return either of these values and nothing else
Here is the question:{question}
Here is the full conversation:{memory}""")return res.content
from langgraph.graph import StateGraph, START, ENDfrom langgraph.graph.message import add_messagesworkflow = Graph()workflow.add_node("agent", agent)workflow.add_edge(START, "agent")workflow.add_edge("agent", END)graph = workflow.compile()graph.invoke('How are you?', 'Nothing')
this returns:
AttributeError: 'str' object has no attribute 'items'
is there an issue with what i defined in my class?
Any help would be sweet! Thanks in advance