langgraph/concepts/human_in_the_loop/ #2290
Replies: 4 comments 3 replies
-
I have a backend, fast api and front end streamlit architecture.... struggling to get this working well. I can edit and resume the graph fine from the back end and fast api using checkpointing. What I cant do well (or cleanly) is trigger a graph update from streamlit front end so the events stream nicely into my existing graph invoke code and event/UI handling. Any insights or code examples for this? |
Beta Was this translation helpful? Give feedback.
-
I have try this and I am still getting from langgraph.graph import StateGraph, MessagesState
from langgraph.types import interrupt, Command
from langgraph.checkpoint.memory import MemorySaver
def human_node(state: MessagesState):
value = interrupt(f"What should I say in response to {state['messages']}")
return {"messages": [{"role": "user", "content": value}]}
checkpointer = MemorySaver()
graph_builder = StateGraph(MessagesState)
graph_builder.add_node(human_node)
graph_builder.set_entry_point("human_node")
graph = graph_builder.compile(
checkpointer=checkpointer
) First call thread_config = {"configurable": {"thread_id": "some_id"}}
graph.invoke({"messages": [{ "role": "user", "content": "Hello!"}]}, config=thread_config) I go the following out put Now resume the graph: graph.invoke(Command(resume="Hello, How can i help you?"), config=thread_config) The output is 2
|
Beta Was this translation helpful? Give feedback.
-
Hey i am using interrupt inside sub graph and when i saw the writes variable of the interrupt |
Beta Was this translation helpful? Give feedback.
-
Hey My interrupt is going in a infinite loop any solutions ? |
Beta Was this translation helpful? Give feedback.
-
langgraph/concepts/human_in_the_loop/
Build language agents as graphs
https://langchain-ai.github.io/langgraph/concepts/human_in_the_loop/
Beta Was this translation helpful? Give feedback.
All reactions