forked from trpc-group/trpc-agent-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_server.py
More file actions
42 lines (31 loc) · 1.22 KB
/
Copy pathrun_server.py
File metadata and controls
42 lines (31 loc) · 1.22 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
# Tencent is pleased to support the open source community by making tRPC-Agent-Python available.
#
# Copyright (C) 2026 Tencent. All rights reserved.
#
# tRPC-Agent-Python is licensed under Apache-2.0.
"""AG-UI Server with Cancel Support
This example starts an AG-UI protocol server that supports automatic
cancellation when the client closes the SSE connection. The agent will
stop at the next checkpoint and partial results are saved to the session.
"""
from dotenv import load_dotenv
from trpc_agent_sdk.sessions import InMemorySessionService
from _agui_runner import create_agui_runner
load_dotenv()
HOST = "127.0.0.1"
PORT = 18080
app_name = "agui_cancel_demo"
def serve():
"""Start the AG-UI server with cancel support."""
service_name = "weather_agent_cancel_service"
uri = "/weather_agent"
from agent.agent import root_agent
session_service = InMemorySessionService()
agui_runner = create_agui_runner(app_name,
service_name,
uri,
root_agent=root_agent,
session_service=session_service)
agui_runner.run(HOST, PORT)
if __name__ == "__main__":
serve()