-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_schemas.py
More file actions
61 lines (43 loc) · 1.56 KB
/
_schemas.py
File metadata and controls
61 lines (43 loc) · 1.56 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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.
"""Pydantic schemas for the TRPC Agent FastAPI server."""
from typing import Any
from typing import List
from typing import Optional
from pydantic import BaseModel
class ChatRequest(BaseModel):
"""Body for POST /v1/chat and POST /v1/chat/stream."""
message: str
session_id: Optional[str] = None
user_id: str = "default"
class ToolEvent(BaseModel):
"""A single tool invocation or result captured during agent execution."""
type: str # "tool_call" or "tool_result"
name: str
data: Any = None
class ChatResponse(BaseModel):
"""Response body for POST /v1/chat (non-streaming)."""
session_id: str
user_id: str
reply: str
tool_events: List[ToolEvent] = []
class StreamChunk(BaseModel):
"""Single Server-Sent Event payload for POST /v1/chat/stream.
type values:
text_delta - incremental text from the agent.
tool_call - agent invoking a tool; data = {"name": str, "args": dict}.
tool_result - tool returned; data = {"name": str, "response": any}.
done - stream finished successfully; data is null.
error - an error occurred; data contains the error message string.
"""
type: str
data: Any = None
session_id: str = ""
class HealthResponse(BaseModel):
"""Response body for GET /health."""
status: str = "ok"
app_name: str
version: str = "1.0.0"