agent.py
5.83 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel, Field
from app.model.agent import AgentStatus
class AgentBase(BaseModel):
name: str = Field(..., max_length=50, description="Agent 名称", examples=["复盘 Agent"])
description: Optional[str] = Field(
None,
max_length=500,
description="Agent 描述信息",
examples=["智能复盘助手,帮助销售进行每日复盘"],
)
status: AgentStatus = Field(
default=AgentStatus.enable,
description="Agent 状态,可选值:enable、disable",
examples=["enable"],
)
class AgentCreate(AgentBase):
position_ids: List[int] = Field(..., description="关联岗位 ID 列表", examples=[[1, 3]])
skill_codes: List[str] = Field(..., description="关联技能编码列表", examples=[["query-metric", "query-detail"]])
managed_user_id: str = Field(
...,
description="托管员工 bot_id。接口这里传的是 wecom_bots.bot_id,服务端会先解析成 wecom_bots.id 后再写入 ai_agents.managed_user_id。",
examples=["RBT001"],
)
class AgentUpdate(AgentBase):
position_ids: Optional[List[int]] = Field(default=None, description="更新后的岗位 ID 列表", examples=[[1, 2]])
skill_codes: Optional[List[str]] = Field(default=None, description="更新后的技能编码列表", examples=[["query-metric"]])
managed_user_id: Optional[str] = Field(
default=None,
description="更新后的托管员工 bot_id。接口这里传的是 wecom_bots.bot_id,服务端会先解析成 wecom_bots.id 后再写入 ai_agents.managed_user_id。",
examples=["RBT001"],
)
class AgentStatusUpdate(BaseModel):
status: AgentStatus = Field(..., description="目标状态", examples=["disable"])
reason: Optional[str] = Field(default=None, description="状态变更原因", examples=["manual disable"])
class AgentPositionItem(BaseModel):
id: int = Field(..., description="岗位 ID", examples=[1])
name: str = Field(..., description="岗位名称", examples=["驻店销售岗"])
class AgentSkillItem(BaseModel):
skill_code: str = Field(..., description="技能编码", examples=["query-metric"])
skill_name: str = Field(..., description="技能名称", examples=["指标查询"])
class AgentUserItem(BaseModel):
user_id: str = Field(..., description="员工 bot_id,对应 wecom_bots.bot_id", examples=["RBT001"])
user_name: str = Field(..., description="员工名称", examples=["张三"])
class AgentResponse(BaseModel):
agent_id: int = Field(..., description="Agent ID", examples=[101])
name: str = Field(..., description="Agent 名称", examples=["复盘 Agent"])
position_ids: List[int] = Field(..., description="岗位 ID 列表", examples=[[1, 3]])
skill_codes: List[str] = Field(..., description="技能编码列表", examples=[["query-metric"]])
managed_user_id: Optional[str] = Field(
default=None,
description="托管员工 bot_id。响应返回的是 wecom_bots.bot_id,不是 ai_agents.managed_user_id 实际存储的整数主键。",
examples=["RBT001"],
)
status: AgentStatus = Field(..., description="Agent 状态", examples=["enable"])
created_at: datetime = Field(..., description="创建时间", examples=["2026-05-21T10:00:00Z"])
class AgentListItemResponse(BaseModel):
agent_id: int = Field(..., description="Agent ID", examples=[101])
name: str = Field(..., description="Agent 名称", examples=["复盘 Agent"])
position_ids: List[int] = Field(..., description="岗位 ID 列表", examples=[[1, 3]])
position_names: List[str] = Field(
default_factory=list,
description="岗位名称列表,与 position_ids 一一对应",
examples=[["驻店销售岗", "门店运营岗"]],
)
skill_codes: List[str] = Field(..., description="技能编码列表", examples=[["query-metric"]])
managed_user_id: Optional[str] = Field(
default=None,
description="托管员工 bot_id。响应返回的是 wecom_bots.bot_id,不是 ai_agents.managed_user_id 实际存储的整数主键。",
examples=["RBT001"],
)
bound_group_count: int = Field(0, description="绑定群数。按该 Agent 对应托管员工的 bot_id 在 wecom_customer_groups.member_bot_ids 中出现的群数量统计。", examples=[3])
status: AgentStatus = Field(..., description="Agent 状态", examples=["enable"])
is_steward: bool = Field(False, description="是否为管家 Agent", examples=[False])
created_at: datetime = Field(..., description="创建时间", examples=["2026-05-21T10:00:00Z"])
class AgentDetailResponse(BaseModel):
agent_id: int = Field(..., description="Agent ID", examples=[101])
name: str = Field(..., description="Agent 名称", examples=["复盘 Agent"])
description: Optional[str] = Field(default=None, description="Agent 描述信息", examples=["智能复盘助手"])
positions: List[AgentPositionItem] = Field(..., description="关联岗位列表")
skills: List[AgentSkillItem] = Field(..., description="关联技能列表")
managed_user: Optional[AgentUserItem] = Field(
default=None,
description="托管员工信息。user_id 返回的是 wecom_bots.bot_id。",
)
status: AgentStatus = Field(..., description="Agent 状态", examples=["enable"])
created_at: datetime = Field(..., description="创建时间", examples=["2026-05-10T09:00:00Z"])
updated_at: datetime = Field(..., description="更新时间", examples=["2026-05-15T10:00:00Z"])
class AgentListResponse(BaseModel):
total: int = Field(..., description="总记录数", examples=[2])
page: int = Field(..., description="当前页码", examples=[1])
page_size: int = Field(..., description="每页数量", examples=[20])
list: List[AgentListItemResponse] = Field(..., description="Agent 列表")