Skip to content

Commit 3e1d34b

Browse files
committed
feat: add getFile function to retrieve file URLs in application and chat modules
1 parent b664ab5 commit 3e1d34b

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

ui/src/api/application/application.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ const postUploadFile: (
401401
return post(`/oss/file`, fd, undefined, loading)
402402
}
403403

404+
405+
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (application_id, params) => {
406+
return get(`/oss/get_url/${application_id}`, params)
407+
}
404408
export default {
405409
getAllApplication,
406410
getApplication,
@@ -430,5 +434,6 @@ export default {
430434
postUploadFile,
431435
generate_prompt,
432436
getTokenUsage,
433-
topQuestions
437+
topQuestions,
438+
getFile
434439
}

ui/src/api/chat/chat.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ const postUploadFile: (
332332
fd.append('source_type', sourceType)
333333
return post(`/oss/file`, fd, undefined, loading)
334334
}
335+
336+
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (application_id, params) => {
337+
return get(`/oss/get_url/${application_id}`, params)
338+
}
335339
export default {
336340
open,
337341
chat,
@@ -362,4 +366,5 @@ export default {
362366
clearChat,
363367
modifyChat,
364368
postUploadFile,
369+
getFile
365370
}

ui/src/api/image.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ const postImage: (data: any) => Promise<Result<any>> = (data) => {
1010
return post(`${prefix}`, data)
1111
}
1212

13-
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (application_id, params) => {
14-
return get(`/oss/get_url/${application_id}`, params)
15-
}
1613
export default {
17-
postImage,
18-
getFile
14+
postImage
1915
}

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ import bus from '@/bus'
419419
import 'recorder-core/src/engine/mp3'
420420
import 'recorder-core/src/engine/mp3-engine'
421421
import chatAPI from '@/api/chat/chat'
422-
import imageApi from '@/api/image'
423422
424423
const router = useRouter()
425424
const route = useRoute()
@@ -1238,7 +1237,11 @@ async function saveUrl() {
12381237
async function processUrl(url: string) {
12391238
try {
12401239
const appId = props.appId || props.applicationDetails?.id;
1241-
const res = await imageApi.getFile(appId, {url})
1240+
const res =
1241+
props.type === 'debug-ai-chat'
1242+
? await applicationApi.getFile(appId, {url})
1243+
: await chatAPI.getFile(appId, {url})
1244+
12421245
if (res.data['status_code'] !== 200) {
12431246
MsgWarning(url + ' ' + t('chat.uploadFile.invalidUrl'));
12441247
return;

0 commit comments

Comments
 (0)