diff --git a/apps/oss/serializers/file.py b/apps/oss/serializers/file.py index c3584caee..ad083b0a7 100644 --- a/apps/oss/serializers/file.py +++ b/apps/oss/serializers/file.py @@ -96,7 +96,7 @@ class FileSerializer(serializers.Serializer): content_type = mime_types.get(file_type, 'application/octet-stream') headers = { 'Content-Type': content_type, - 'Content-Disposition': f'attachment; filename="{file.file_name}"' + 'Content-Disposition': f'{"inline" if file_type == "pdf" else "attachment"}; filename="{file.file_name}"' } return HttpResponse( file.get_bytes(), diff --git a/ui/src/components/ai-chat/component/knowledge-source-component/index.vue b/ui/src/components/ai-chat/component/knowledge-source-component/index.vue index a1760ebde..00e268770 100644 --- a/ui/src/components/ai-chat/component/knowledge-source-component/index.vue +++ b/ui/src/components/ai-chat/component/knowledge-source-component/index.vue @@ -20,14 +20,14 @@

{{ item && item?.document_name }}

{ + return item.document_name.toLocaleLowerCase().endsWith('.pdf') && item.meta?.source_file_id +} const dialogVisible = ref(false) const dialogTitle = ref('') const currentComponent = shallowRef(null) diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts index 11ee7ad02..596112a71 100644 --- a/ui/src/utils/common.ts +++ b/ui/src/utils/common.ts @@ -143,6 +143,12 @@ export function getNormalizedUrl(url: string) { } return url } +export function getFileUrl(fileId?: string) { + if (fileId) { + return `${window.MaxKB.prefix}/oss/file/${fileId}` + } + return '' +} export const resetUrl = (url: string, defaultUrl?: string) => { if (url && url.startsWith('./')) { return `${window.MaxKB.prefix}/${url.substring(2)}`