feat: 前端搭建
This commit is contained in:
15
Yi.Ai.Vue3/src/api/chat/index.ts
Normal file
15
Yi.Ai.Vue3/src/api/chat/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { ChatMessageVo, GetChatListParams, SendDTO } from './types';
|
||||
import { get, post } from '@/utils/request';
|
||||
|
||||
// 发送消息
|
||||
export const send = (data: SendDTO) => post<null>('/chat/send', data);
|
||||
|
||||
// 新增对应会话聊天记录
|
||||
export function addChat(data: ChatMessageVo) {
|
||||
return post('/system/message', data);
|
||||
}
|
||||
|
||||
// 获取当前会话的聊天记录
|
||||
export function getChatList(params: GetChatListParams) {
|
||||
return get<ChatMessageVo[]>('/system/message/list', params);
|
||||
}
|
||||
222
Yi.Ai.Vue3/src/api/chat/types.ts
Normal file
222
Yi.Ai.Vue3/src/api/chat/types.ts
Normal file
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
* ChatRequest,描述:对话请求对象
|
||||
*/
|
||||
export interface SendDTO {
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
appId?: string;
|
||||
/**
|
||||
* 上下文的条数
|
||||
*/
|
||||
contentNumber?: number;
|
||||
/**
|
||||
* 是否开启mcp
|
||||
*/
|
||||
isMcp?: boolean;
|
||||
/**
|
||||
* 知识库id
|
||||
*/
|
||||
kid?: string;
|
||||
messages: Message[];
|
||||
// model: ModelType;
|
||||
model?: string;
|
||||
/**
|
||||
* 提示词
|
||||
*/
|
||||
prompt?: string;
|
||||
/**
|
||||
* 是否开启联网搜索(0关闭 1开启)
|
||||
*/
|
||||
search?: boolean;
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
sessionId?: string;
|
||||
/**
|
||||
* 是否开启流式对话
|
||||
*/
|
||||
stream?: boolean;
|
||||
/**
|
||||
* 系统提示词
|
||||
*/
|
||||
sysPrompt?: string;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
/**
|
||||
* 是否携带上下文
|
||||
*/
|
||||
usingContext?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message,描述:
|
||||
*/
|
||||
export interface Message {
|
||||
content?: string;
|
||||
name?: string;
|
||||
reasoning_content?: string;
|
||||
/**
|
||||
* 目前支持四个中角色参考官网,进行情景输入:
|
||||
* https://platform.openai.com/docs/guides/chat/introduction
|
||||
*/
|
||||
role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
|
||||
tool_call_id?: string;
|
||||
/**
|
||||
* The tool calls generated by the model, such as function calls.
|
||||
*/
|
||||
tool_calls?: ToolCalls[];
|
||||
}
|
||||
|
||||
/**
|
||||
* ToolCalls,The tool calls generated by the model, such as function calls.
|
||||
*/
|
||||
export interface ToolCalls {
|
||||
function?: ToolCallFunction;
|
||||
/**
|
||||
* The ID of the tool call.
|
||||
*/
|
||||
id?: string;
|
||||
/**
|
||||
* The type of the tool. Currently, only function is supported.
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ToolCallFunction,ToolCall 的 Function参数
|
||||
* The function that the model called.
|
||||
*/
|
||||
export interface ToolCallFunction {
|
||||
/**
|
||||
* 方法参数
|
||||
*/
|
||||
arguments?: string;
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface GetChatListParams {
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
createBy?: number;
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
createDept?: number;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime?: Date;
|
||||
/**
|
||||
* 扣除金额
|
||||
*/
|
||||
deductCost?: number;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: number;
|
||||
/**
|
||||
* 排序的方向desc或者asc
|
||||
*/
|
||||
isAsc?: string;
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
modelName?: string;
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
orderByColumn?: string;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
pageNum?: number;
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
params?: { [key: string]: { [key: string]: any } };
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 对话角色
|
||||
*/
|
||||
role?: string;
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
sessionId?: string;
|
||||
/**
|
||||
* 累计 Tokens
|
||||
*/
|
||||
totalTokens?: number;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
updateBy?: number;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
updateTime?: Date;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatMessageVo,聊天消息视图对象 chat_message
|
||||
*/
|
||||
export interface ChatMessageVo {
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* 扣除金额
|
||||
*/
|
||||
deductCost?: number;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: number;
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
modelName?: string;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
/**
|
||||
* 对话角色
|
||||
*/
|
||||
role?: string;
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
sessionId?: number;
|
||||
/**
|
||||
* 累计 Tokens
|
||||
*/
|
||||
totalTokens?: number;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
userId?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user