-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage_example.py
More file actions
46 lines (31 loc) · 1.13 KB
/
Copy pathusage_example.py
File metadata and controls
46 lines (31 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Minimal LangGraph usage example for Entire Adapter.
Run setup once from a git repository:
pip install -e .
entire enable --agent langgraph --telemetry=false
Then pass the callback in the graph invoke config.
"""
from __future__ import annotations
from typing import TypedDict
from entire_adapter import EntireCallbackHandler
class AgentState(TypedDict):
prompt: str
answer: str
def answer_node(state: AgentState) -> AgentState:
# Replace this with your actual model/tool pipeline.
return {"prompt": state["prompt"], "answer": f"Processed: {state['prompt']}"}
def build_graph():
from langgraph.graph import END, START, StateGraph
graph = StateGraph(AgentState)
graph.add_node("answer", answer_node)
graph.add_edge(START, "answer")
graph.add_edge("answer", END)
return graph.compile()
if __name__ == "__main__":
app = build_graph()
entire = EntireCallbackHandler(agent_label="demo-langgraph")
result = app.invoke(
{"prompt": "Update the project safely"},
config={"callbacks": [entire]},
)
print(result)
print(f"Entire session: {entire.session_id}")