feat(chat): 为聊天功能添加上传本地文件和远程URL附件的支持
This commit is contained in:
1 parent
2a036764e3
commit
a1e0fa9404
7 files changed
+1024
-17
No files matched your search
@@ -34,6 +34,15 @@ export interface ChatSourceFileResult {
|
||||
source_ext?: string;
|
||||
}
|
||||
|
||||
export interface ChatUploadResult {
|
||||
id: string;
|
||||
name?: string;
|
||||
size?: number;
|
||||
extension?: string;
|
||||
mime_type?: string;
|
||||
type?: 'image' | 'document' | 'audio' | 'video' | 'custom';
|
||||
}
|
||||
|
||||
export const listChatSessions = (agentId: number) =>
|
||||
requestJson<ChatSessionItem[]>(`/api/chat/sessions?agent_id=${agentId}`, auth());
|
||||
|
||||
@@ -78,3 +87,14 @@ export const listOaEmployees = (
|
||||
});
|
||||
return requestJson<OaEmployeesResponse>(`/api/chat/oa/employees?${qs.toString()}`, auth());
|
||||
};
|
||||
|
||||
export const uploadChatFile = (agentId: number, file: File) => {
|
||||
const qs = new URLSearchParams({ agent_id: String(agentId) });
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
return requestJson<ChatUploadResult>(`/api/chat/files/upload?${qs.toString()}`, {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user