Spaces:
Sleeping
Sleeping
Download agents/main.py from anil988/SentinelFin-AI-Backend: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/anil988/SentinelFin-AI-Backend/resolve/main/agents/main.py
- Command line
-
hf download hf://spaces/anil988/SentinelFin-AI-Backend/agents/main.py
-
curl -L -o main.py https://huggingface.co/spaces/anil988/SentinelFin-AI-Backend/resolve/main/agents/main.py
1.19 kB
| from langchain_core.messages import HumanMessage, SystemMessage | |
| from langgraph.graph import START, StateGraph, END | |
| from uipath_langchain.chat import ( | |
| UiPathAzureChatOpenAI, | |
| UiPathChatAnthropicBedrock, | |
| UiPathChatGoogleGenerativeAI, | |
| ) | |
| from pydantic import BaseModel | |
| class GraphState(BaseModel): | |
| topic: str | |
| class GraphOutput(BaseModel): | |
| report: str | |
| async def generate_report(state: GraphState) -> GraphOutput: | |
| # Choose your LLM provider by uncommenting one of the following: | |
| llm = UiPathChatAnthropicBedrock(model="meta.llama3-1-70b-instruct-v1:0") | |
| # llm = UiPathAzureChatOpenAI(model="gpt-4.1-mini-2025-04-14") | |
| # llm = UiPathChatGoogleGenerativeAI(model="gemini-2.5-flash") | |
| 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() | |