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.
"""A2A Server Example
This example uses the standard A2A SDK server (A2AStarletteApplication) to serve
a trpc-agent as an A2A service over plain HTTP, with the standard protocol
(artifact-first streaming and unprefixed metadata keys).
"""
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_demo"
def serve():
"""Start the A2A server using standard HTTP (uvicorn + Starlette)."""
service_name = "weather_agent_standard_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()