-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
25 lines (19 loc) · 716 Bytes
/
agent.py
File metadata and controls
25 lines (19 loc) · 716 Bytes
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
from typing import TypedDict, Annotated
from langgraph.graph import StateGraph, START, END
# 1. Define the State (the data passed between nodes)
class State(TypedDict):
input_text: str
response: str
# 2. Define the Nodes (the logic functions)
def greeting_node(state: State):
print("---LOG: Processing in Greeting Node---")
return {"response": f"Hello! You said: '{state['input_text']}'"}
# 3. Build the Graph
workflow = StateGraph(State)
# Add our node to the graph
workflow.add_node("greeter", greeting_node)
# Define the flow: Start -> Greeter -> End
workflow.add_edge(START, "greeter")
workflow.add_edge("greeter", END)
# 4. Export the graph for LangGraph Studio
graph = workflow.compile()