feat: add getFile function to retrieve file URLs in application and chat modules

This commit is contained in:
wxg0103 2025-12-04 18:24:33 +08:00
parent b664ab571f
commit 3e1d34b83d
4 changed files with 17 additions and 8 deletions

View File

@ -401,6 +401,10 @@ const postUploadFile: (
return post(`/oss/file`, fd, undefined, loading)
}
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (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
}

View File

@ -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<Result<any>> = (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
}

View File

@ -10,10 +10,6 @@ const postImage: (data: any) => Promise<Result<any>> = (data) => {
return post(`${prefix}`, data)
}
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (application_id, params) => {
return get(`/oss/get_url/${application_id}`, params)
}
export default {
postImage,
getFile
postImage
}

View File

@ -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;