fix: 接口对接

This commit is contained in:
Json_Lee
2025-05-12 20:13:09 +08:00
parent 11ce542b5d
commit 7ccfc4a10c
10 changed files with 355 additions and 20 deletions
+8
View File
@@ -0,0 +1,8 @@
import type { ChatMessageVo, GetChatListParams, SendDTO } from './types';
import { get, post } from '@/utils/request';
export const send = (data: SendDTO) => post<null>('/chat/send', data).stream();
export function getChatList(params: GetChatListParams) {
return get<ChatMessageVo[]>('/system/message/list', params);
}
+221
View File
@@ -0,0 +1,221 @@
/**
* ChatRequest,描述:对话请求对象
*/
export interface SendDTO {
/**
* 应用ID
*/
appId?: string;
/**
* 上下文的条数
*/
contentNumber?: number;
/**
* 是否开启mcp
*/
isMcp?: boolean;
/**
* 知识库id
*/
kid?: string;
messages: Message[];
model: string;
/**
* 提示词
*/
prompt?: string;
/**
* 是否开启联网搜索(0关闭 1开启)
*/
search?: boolean;
/**
* 会话id
*/
sessionId?: number;
/**
* 是否开启流式对话
*/
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?: number;
/**
* 累计 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;
}
+2 -1
View File
@@ -1,6 +1,7 @@
import type {
ChatSessionVo,
CreateSessionDTO,
CreateSessionVO,
GetSessionListParams,
} from './types';
import { get, post } from '@/utils/request';
@@ -10,5 +11,5 @@ export function getSessionList(params: GetSessionListParams) {
}
export function createSession(data: CreateSessionDTO) {
return post<null>('/system/session', data);
return post<CreateSessionVO>('/system/session', data);
}
+4
View File
@@ -136,3 +136,7 @@ export interface CreateSessionDTO {
*/
userId: number;
}
export interface CreateSessionVO {
id: number;
}