| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // api/subagent.ts:子智能体(列表 / 工具注册表 / 增删改查 / 启停)。
- import { defHttp } from '/@/utils/http/axios/index';
- import type { SubAgent, SubAgentToolGroup } from '/@/views/ventAI/manageAssistent/types/index';
- enum Api {
- subagents = '/ventAI/api/subagents',
- }
- /**
- * 获取子智能体列表。
- * 契约已对真实响应核实:{ subagents: SubAgent[] };tool_infos 项形状统一为 { name, display_name, exists }。
- * 响应外壳在此拆掉,调用方直接拿到数组,不再各自猜 subagents / data / 裸数组。
- */
- export const getSubAgents = async (): Promise<SubAgent[]> => {
- const res = await defHttp.get({ url: Api.subagents }, { isTransformResponse: false });
- return res?.subagents ?? [];
- };
- /**
- * 获取子智能体表单可选用的工具注册表。
- * 契约已对真实响应核实:{ groups: SubAgentToolGroup[] };响应中不存在 models 字段。
- */
- export const getSubAgentTools = async (): Promise<SubAgentToolGroup[]> => {
- const res = await defHttp.get({ url: `${Api.subagents}/tools` }, { isTransformResponse: false });
- return res?.groups ?? [];
- };
- /**
- * 创建子智能体
- */
- export const createSubAgent = (data: {
- name: string;
- description: string;
- system_prompt: string;
- tools?: string[];
- model?: string;
- enabled?: boolean;
- }) => defHttp.post({ url: Api.subagents, data }, { isTransformResponse: false });
- /**
- * 获取子智能体详情(当前无调用方,保留以镜像后端接口)
- */
- export const getSubAgentDetail = (name: string) => defHttp.get({ url: `${Api.subagents}/${name}` }, { isTransformResponse: false });
- /**
- * 更新子智能体
- */
- export const updateSubAgent = (
- name: string,
- data: { description?: string; system_prompt?: string; tools?: string[]; model?: string; enabled?: boolean }
- ) => defHttp.put({ url: `${Api.subagents}/${name}`, data }, { isTransformResponse: false });
- /**
- * 删除子智能体
- */
- export const deleteSubAgent = (name: string) => defHttp.delete({ url: `${Api.subagents}/${name}` }, { isTransformResponse: false });
- /**
- * 启用/禁用子智能体
- */
- export const toggleSubAgent = (name: string) => defHttp.post({ url: `${Api.subagents}/${name}/toggle` }, { isTransformResponse: false });
|