-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathmain.py.template
More file actions
32 lines (20 loc) · 876 Bytes
/
main.py.template
File metadata and controls
32 lines (20 loc) · 876 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
26
27
28
29
30
31
32
from langchain_core.messages import HumanMessage, SystemMessage
from langgraph.graph import START, StateGraph, END
from uipath_langchain.chat import UiPathChat
from pydantic import BaseModel
llm = UiPathChat(model="gpt-4.1-mini-2025-04-14")
class GraphState(BaseModel):
topic: str
class GraphOutput(BaseModel):
report: str
async def generate_report(state: GraphState) -> GraphOutput:
system_prompt = "You are a report generator. Please provide a brief report based on the given topic."
output = await llm.ainvoke(
[SystemMessage(system_prompt), HumanMessage(state.topic)]
)
return GraphOutput(report=output.content)
builder = StateGraph(GraphState, output=GraphOutput)
builder.add_node("generate_report", generate_report)
builder.add_edge(START, "generate_report")
builder.add_edge("generate_report", END)
graph = builder.compile()