feat: 完成意心ai agent
This commit is contained in:
25
Yi.Ai.Vue3/src/api/agent/index.ts
Normal file
25
Yi.Ai.Vue3/src/api/agent/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { AgentSendInput, AgentToolOutput } from './types';
|
||||
import { get, post } from '@/utils/request';
|
||||
|
||||
/**
|
||||
* Agent 发送消息
|
||||
*/
|
||||
export function agentSend(data: AgentSendInput) {
|
||||
return post('/ai-chat/agent/send', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Agent 工具列表
|
||||
*/
|
||||
export function getAgentTools() {
|
||||
return post<AgentToolOutput[]>('/ai-chat/agent/tool').json();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Agent 上下文
|
||||
*/
|
||||
export function getAgentContext(sessionId: string) {
|
||||
return post<string>(`/ai-chat/agent/context/${sessionId}`).json();
|
||||
}
|
||||
|
||||
export * from './types';
|
||||
51
Yi.Ai.Vue3/src/api/agent/types.ts
Normal file
51
Yi.Ai.Vue3/src/api/agent/types.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Agent 发送消息输入
|
||||
*/
|
||||
export interface AgentSendInput {
|
||||
/** 会话id */
|
||||
sessionId: string;
|
||||
/** 用户内容 */
|
||||
content: string;
|
||||
/** api密钥Id */
|
||||
tokenId: string;
|
||||
/** 模型id */
|
||||
modelId: string;
|
||||
/** 已选择工具 */
|
||||
tools: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent 工具输出
|
||||
*/
|
||||
export interface AgentToolOutput {
|
||||
/** 工具代码 */
|
||||
code: string;
|
||||
/** 工具名称 */
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent 结果类型
|
||||
*/
|
||||
export type AgentResultType = 'text' | 'toolCalling' | 'toolCalled' | 'usage' | 'toolCallUsage';
|
||||
|
||||
/**
|
||||
* Agent 流式结果输出
|
||||
*/
|
||||
export interface AgentResultOutput {
|
||||
/** 类型 */
|
||||
type: AgentResultType;
|
||||
/** 内容载体 */
|
||||
content: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent 用量信息
|
||||
*/
|
||||
export interface AgentUsage {
|
||||
input_tokens?: number;
|
||||
output_tokens?: number;
|
||||
total_tokens?: number;
|
||||
prompt_tokens?: number;
|
||||
completion_tokens?: number;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './announcement'
|
||||
export * from './agent';
|
||||
export * from './auth';
|
||||
export * from './chat';
|
||||
export * from './file';
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import type { Component } from 'vue';
|
||||
|
||||
/**
|
||||
* 会话类型枚举
|
||||
*/
|
||||
export enum SessionTypeEnum {
|
||||
/** 普通聊天 */
|
||||
Chat = 0,
|
||||
/** Agent智能体 */
|
||||
Agent = 1,
|
||||
}
|
||||
|
||||
export interface GetSessionListParams {
|
||||
/**
|
||||
* 创建者
|
||||
@@ -61,6 +71,10 @@ export interface GetSessionListParams {
|
||||
* 用户id
|
||||
*/
|
||||
userId: number;
|
||||
/**
|
||||
* 会话类型
|
||||
*/
|
||||
sessionType?: SessionTypeEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,6 +110,10 @@ export interface ChatSessionVo {
|
||||
* 自定义的消息前缀图标字段
|
||||
*/
|
||||
prefixIcon?: Component;
|
||||
/**
|
||||
* 会话类型
|
||||
*/
|
||||
sessionType?: SessionTypeEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,6 +165,10 @@ export interface CreateSessionDTO {
|
||||
* 用户id
|
||||
*/
|
||||
userId: number;
|
||||
/**
|
||||
* 会话类型
|
||||
*/
|
||||
sessionType?: SessionTypeEnum;
|
||||
}
|
||||
|
||||
// export interface CreateSessionVO {
|
||||
|
||||
Reference in New Issue
Block a user