add AiConversationList.vue
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { axios } from "timi-web-api";
|
||||
|
||||
/** 门店智能助手聊天请求。 */
|
||||
export interface GaoAiChatRequest {
|
||||
message: string;
|
||||
@@ -6,6 +8,58 @@ export interface GaoAiChatRequest {
|
||||
storeId?: string;
|
||||
}
|
||||
|
||||
/** 历史会话列表排序方式。 */
|
||||
export type GaoAiConversationSortBy = "created_at" | "-created_at" | "updated_at" | "-updated_at";
|
||||
|
||||
/** 历史会话列表请求。 */
|
||||
export interface GaoAiConversationListRequest {
|
||||
lastId?: string;
|
||||
limit?: number;
|
||||
sortBy?: GaoAiConversationSortBy;
|
||||
}
|
||||
|
||||
/** 历史会话。 */
|
||||
export interface GaoAiConversation {
|
||||
id: string;
|
||||
name?: string;
|
||||
status?: string;
|
||||
introduction?: string;
|
||||
"created_at"?: number | string;
|
||||
"updated_at"?: number | string;
|
||||
}
|
||||
|
||||
/** 历史会话列表响应。 */
|
||||
export interface GaoAiConversationListResponse {
|
||||
"has_more"?: boolean;
|
||||
limit?: number;
|
||||
data?: GaoAiConversation[];
|
||||
}
|
||||
|
||||
/** 历史会话消息读取请求。 */
|
||||
export interface GaoAiConversationReadRequest {
|
||||
conversationId: string;
|
||||
firstId?: string;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
/** 历史会话消息。 */
|
||||
export interface GaoAiConversationMessage {
|
||||
id: string;
|
||||
"conversation_id"?: string;
|
||||
query?: string;
|
||||
answer?: string;
|
||||
"created_at"?: number | string;
|
||||
status?: string;
|
||||
feedback?: unknown;
|
||||
}
|
||||
|
||||
/** 历史会话消息列表响应。 */
|
||||
export interface GaoAiConversationReadResponse {
|
||||
"has_more"?: boolean;
|
||||
limit?: number;
|
||||
data?: GaoAiConversationMessage[];
|
||||
}
|
||||
|
||||
/** 智能助手 SSE 事件。 */
|
||||
export interface GaoAiStreamEvent {
|
||||
event: string;
|
||||
@@ -37,6 +91,40 @@ export class GaoAiStreamError extends Error {
|
||||
}
|
||||
|
||||
const chatPath = "/gao/ai/chat";
|
||||
const conversationBasePath = "/gao/ai/conversation";
|
||||
|
||||
/**
|
||||
* 查询当前登录用户的历史会话。
|
||||
*
|
||||
* @param request 历史会话分页请求
|
||||
*/
|
||||
export async function listConversations(
|
||||
request: GaoAiConversationListRequest = {}
|
||||
): Promise<GaoAiConversationListResponse> {
|
||||
return await axios.post(`${conversationBasePath}/list`, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定历史会话的消息。
|
||||
*
|
||||
* @param request 历史会话读取请求
|
||||
*/
|
||||
export async function readConversation(
|
||||
request: GaoAiConversationReadRequest
|
||||
): Promise<GaoAiConversationReadResponse> {
|
||||
return await axios.post(`${conversationBasePath}/read`, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定历史会话。
|
||||
*
|
||||
* @param conversationId 会话 ID
|
||||
*/
|
||||
export async function deleteConversation(conversationId: string): Promise<void> {
|
||||
await axios.post(`${conversationBasePath}/delete`, undefined, {
|
||||
params: { conversationId }
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起门店智能助手聊天请求。
|
||||
|
||||
Reference in New Issue
Block a user