From 3e1d34b83de96ab53042d321ede52d902499304b Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 4 Dec 2025 18:24:33 +0800 Subject: [PATCH] feat: add getFile function to retrieve file URLs in application and chat modules --- ui/src/api/application/application.ts | 7 ++++++- ui/src/api/chat/chat.ts | 5 +++++ ui/src/api/image.ts | 6 +----- .../ai-chat/component/chat-input-operate/index.vue | 7 +++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ui/src/api/application/application.ts b/ui/src/api/application/application.ts index 5502b2929..9592baae7 100644 --- a/ui/src/api/application/application.ts +++ b/ui/src/api/application/application.ts @@ -401,6 +401,10 @@ const postUploadFile: ( return post(`/oss/file`, fd, undefined, loading) } + +const getFile: (application_id: string, params: any) => Promise> = (application_id, params) => { + return get(`/oss/get_url/${application_id}`, params) +} export default { getAllApplication, getApplication, @@ -430,5 +434,6 @@ export default { postUploadFile, generate_prompt, getTokenUsage, - topQuestions + topQuestions, + getFile } diff --git a/ui/src/api/chat/chat.ts b/ui/src/api/chat/chat.ts index dde551501..5333dd01a 100644 --- a/ui/src/api/chat/chat.ts +++ b/ui/src/api/chat/chat.ts @@ -332,6 +332,10 @@ const postUploadFile: ( fd.append('source_type', sourceType) return post(`/oss/file`, fd, undefined, loading) } + +const getFile: (application_id: string, params: any) => Promise> = (application_id, params) => { + return get(`/oss/get_url/${application_id}`, params) +} export default { open, chat, @@ -362,4 +366,5 @@ export default { clearChat, modifyChat, postUploadFile, + getFile } diff --git a/ui/src/api/image.ts b/ui/src/api/image.ts index e9715daf3..7508b77e1 100644 --- a/ui/src/api/image.ts +++ b/ui/src/api/image.ts @@ -10,10 +10,6 @@ const postImage: (data: any) => Promise> = (data) => { return post(`${prefix}`, data) } -const getFile: (application_id: string, params: any) => Promise> = (application_id, params) => { - return get(`/oss/get_url/${application_id}`, params) -} export default { - postImage, - getFile + postImage } diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index f06cec514..747fa5828 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -419,7 +419,6 @@ import bus from '@/bus' import 'recorder-core/src/engine/mp3' import 'recorder-core/src/engine/mp3-engine' import chatAPI from '@/api/chat/chat' -import imageApi from '@/api/image' const router = useRouter() const route = useRoute() @@ -1238,7 +1237,11 @@ async function saveUrl() { async function processUrl(url: string) { try { const appId = props.appId || props.applicationDetails?.id; - const res = await imageApi.getFile(appId, {url}) + const res = + props.type === 'debug-ai-chat' + ? await applicationApi.getFile(appId, {url}) + : await chatAPI.getFile(appId, {url}) + if (res.data['status_code'] !== 200) { MsgWarning(url + ' ' + t('chat.uploadFile.invalidUrl')); return;