增加def get_my_local_agent_list端点

This commit is contained in:
jingrow 2025-11-03 00:04:11 +08:00
parent 4d6278a8d6
commit 81ffc451af

View File

@ -338,3 +338,64 @@ def get_my_local_node_list(filters=None, order_by=None, limit_start=None, limit_
result.append(node_data) result.append(node_data)
return result return result
@dashboard_whitelist()
def get_my_local_agent_list(filters=None, order_by=None, limit_start=None, limit_page_length=None):
"""获取当前团队的Agent列表"""
team = get_current_team()
if not team:
return {"success": False, "message": "未找到当前团队信息"}
# 构建查询条件
query_filters = {"team": team}
if filters:
if isinstance(filters, str):
import json
filters = json.loads(filters)
query_filters.update(filters)
# 默认排序
if not order_by:
order_by = "agent_name asc"
# 获取Agent列表
agents = jingrow.get_all(
"Local Agent",
filters=query_filters,
fields=[
"name", "agent_name", "title", "subtitle",
"enabled", "public", "team", "status", "repository_url",
"file_url", "agent_image", "creation", "modified"
],
order_by=order_by,
limit_start=limit_start,
limit_page_length=limit_page_length
)
# 批量获取团队用户名称
team_user_names = _get_team_user_names(agents)
# 格式化返回数据
result = []
for agent in agents:
agent_data = {
"name": agent.name,
"agent_name": agent.agent_name,
"title": agent.title,
"subtitle": agent.subtitle,
"enabled": agent.enabled,
"public": agent.public,
"team": team_user_names.get(agent.team),
"status": agent.status,
"repository_url": agent.repository_url,
"file_url": agent.file_url,
"agent_image": agent.agent_image,
"creation": agent.creation,
"modified": agent.modified
}
result.append(agent_data)
return result