112 lines
2.8 KiB
TypeScript
112 lines
2.8 KiB
TypeScript
import type {AgentInfo, AgentKnowledgeBinding, AgentToolBinding,} from './types';
|
|
|
|
import {api} from '#/api/request';
|
|
|
|
export interface RequestResult<T = any> {
|
|
data: T;
|
|
errorCode: number;
|
|
message?: string;
|
|
}
|
|
|
|
export function getAgentDetail(id: number | string) {
|
|
return api.get<RequestResult<AgentInfo>>('/api/v1/agent/getDetail', {
|
|
params: { id },
|
|
});
|
|
}
|
|
|
|
export function saveAgent(agent: AgentInfo) {
|
|
return api.post<RequestResult<AgentInfo>>('/api/v1/agent/save', agent);
|
|
}
|
|
|
|
export function updateAgent(agent: AgentInfo) {
|
|
return api.post<RequestResult<AgentInfo>>('/api/v1/agent/update', agent);
|
|
}
|
|
|
|
export function removeAgent(id: number | string) {
|
|
return api.post<RequestResult>('/api/v1/agent/remove', { id });
|
|
}
|
|
|
|
export function updateAgentToolBindings(
|
|
agentId: number | string,
|
|
bindings: AgentToolBinding[],
|
|
) {
|
|
return api.post<RequestResult<AgentToolBinding[]>>(
|
|
'/api/v1/agent/toolBinding/update',
|
|
{ agentId, bindings },
|
|
);
|
|
}
|
|
|
|
export function updateAgentKnowledgeBindings(
|
|
agentId: number | string,
|
|
bindings: AgentKnowledgeBinding[],
|
|
) {
|
|
return api.post<RequestResult<AgentKnowledgeBinding[]>>(
|
|
'/api/v1/agent/knowledgeBinding/update',
|
|
{ agentId, bindings },
|
|
);
|
|
}
|
|
|
|
export function submitAgentPublishApproval(id: number | string) {
|
|
return api.post<RequestResult<number | string>>(
|
|
'/api/v1/agent/submitPublishApproval',
|
|
{ id },
|
|
);
|
|
}
|
|
|
|
export function submitAgentOfflineApproval(id: number | string) {
|
|
return api.post<RequestResult<number | string>>(
|
|
'/api/v1/agent/submitOfflineApproval',
|
|
{ id },
|
|
);
|
|
}
|
|
|
|
export function submitAgentDeleteApproval(id: number | string) {
|
|
return api.post<RequestResult<number | string>>(
|
|
'/api/v1/agent/submitDeleteApproval',
|
|
{ id },
|
|
);
|
|
}
|
|
|
|
export function approveAgentRun(requestId: string, resumeToken: string) {
|
|
return api.post<RequestResult>('/api/v1/agent/run/approve', {
|
|
requestId,
|
|
resumeToken,
|
|
});
|
|
}
|
|
|
|
export function rejectAgentRun(
|
|
requestId: string,
|
|
resumeToken: string,
|
|
reason?: string,
|
|
) {
|
|
return api.post<RequestResult>('/api/v1/agent/run/reject', {
|
|
requestId,
|
|
resumeToken,
|
|
reason,
|
|
});
|
|
}
|
|
|
|
export function clearAgentDraftSession(sessionId: string) {
|
|
return api.post<RequestResult>('/api/v1/agent/chat/draft/clear', {
|
|
sessionId,
|
|
});
|
|
}
|
|
|
|
export function getAgentCategories() {
|
|
return api.get<RequestResult<any[]>>('/api/v1/agentCategory/visibleList', {
|
|
params: { sortKey: 'sortNo', sortType: 'asc' },
|
|
});
|
|
}
|
|
|
|
export function getAgentModels() {
|
|
return api.get<RequestResult<any[]>>('/api/v1/model/list', {
|
|
params: { modelType: 'chatModel', added: true },
|
|
});
|
|
}
|
|
|
|
export function getPublishedKnowledgeList() {
|
|
return api.get<RequestResult<any[]>>('/api/v1/documentCollection/list', {
|
|
params: { publishedOnly: true },
|
|
});
|
|
}
|