AI 对话web、wx优化

This commit is contained in:
2025-12-29 12:49:23 +08:00
parent 02aed37287
commit 6a2544e964
11 changed files with 960 additions and 139 deletions

View File

@@ -1,4 +1,4 @@
import { request } from '../base'
import { request, uploadFile } from '../base'
import type { ResultDomain } from '../../types'
import type {
TbChat,
@@ -11,7 +11,8 @@ import type {
ChatMessageListParam,
SSECallbacks,
SSETask,
SSEMessageData
SSEMessageData,
DifyFileInfo
} from '../../types/ai/aiChat'
/* eslint-disable @typescript-eslint/no-explicit-any */
@@ -190,5 +191,21 @@ export const aiChatAPI = {
*/
commentChatMessage(param: CommentMessageParam): Promise<ResultDomain<boolean>> {
return request<boolean>({ url: `${this.baseUrl}/comment`, method: 'POST', data: param })
},
// ====================== 文件上传 ======================
/**
* 上传文件用于对话(图文多模态)
* @param filePath 文件临时路径
* @param agentId 智能体ID
*/
uploadFileForChat(filePath: string, agentId: string): Promise<ResultDomain<DifyFileInfo>> {
return uploadFile<DifyFileInfo>({
url: `${this.baseUrl}/file/upload`,
filePath: filePath,
name: 'file',
formData: { agentId: agentId }
})
}
}