Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(frontend): follow configured upload limit in hints (#4110)
hahahahahayesyeseys6e2e5d8bb07c
diff --git a/frontend/src/components/empty-knowledge.vue b/frontend/src/components/empty-knowledge.vueindex 1b8ad3464..ebda86d47 100644--- a/frontend/src/components/empty-knowledge.vue+++ b/frontend/src/components/empty-knowledge.vue@@ -1,13 +1,12 @@<script setup lang="ts">-import { useI18n } from 'vue-i18n'-const { t } = useI18n()+import { MAX_FILE_SIZE_MB } from '@/utils'</script><template><div class="empty"><img class="empty-img" src="@/assets/img/upload.svg" alt=""><span class="empty-txt">{{ $t('knowledgeBase.emptyKnowledgeDragDrop') }}</span>- <span class="empty-type-txt">{{ $t('knowledgeBase.pdfDocFormat') }}</span>- <span class="empty-type-txt">{{ $t('knowledgeBase.textMarkdownFormat') }}</span>+ <span class="empty-type-txt">{{ $t('knowledgeBase.pdfDocFormat', { size: MAX_FILE_SIZE_MB }) }}</span>+ <span class="empty-type-txt">{{ $t('knowledgeBase.textMarkdownFormat', { size: MAX_FILE_SIZE_MB }) }}</span></div></template><style scoped lang="less">diff --git a/frontend/src/components/upload-limit-copy.test.ts b/frontend/src/components/upload-limit-copy.test.tsnew file mode 100644index 000000000..d4e945b56--- /dev/null+++ b/frontend/src/components/upload-limit-copy.test.ts@@ -0,0 +1,51 @@+import assert from 'node:assert/strict'+import { readFileSync } from 'node:fs'+import test from 'node:test'+import { createI18n } from 'vue-i18n'++import enUS from '../i18n/locales/en-US.ts'+import jaJP from '../i18n/locales/ja-JP.ts'+import koKR from '../i18n/locales/ko-KR.ts'+import ruRU from '../i18n/locales/ru-RU.ts'+import zhCN from '../i18n/locales/zh-CN.ts'+import zhTW from '../i18n/locales/zh-TW.ts'++const messages = {+ 'en-US': enUS,+ 'ja-JP': jaJP,+ 'ko-KR': koKR,+ 'ru-RU': ruRU,+ 'zh-CN': zhCN,+ 'zh-TW': zhTW,+}++test('knowledge upload hints interpolate the configured limit in every locale', () => {+ const size = 73++ for (const locale of Object.keys(messages)) {+ const i18n = createI18n({ legacy: false, locale, messages })+ const pdfDoc = i18n.global.t('knowledgeBase.pdfDocFormat', { size })+ const textMarkdown = i18n.global.t('knowledgeBase.textMarkdownFormat', { size })++ assert.match(pdfDoc, /73/, `${locale}: pdf/doc hint`)+ assert.match(textMarkdown, /73/, `${locale}: text/markdown hint`)+ }+})++test('empty state and drag overlay pass the runtime limit to both upload hints', () => {+ for (const name of ['empty-knowledge.vue', 'upload-mask.vue']) {+ const source = readFileSync(new URL(`./${name}`, import.meta.url), 'utf8')++ assert.match(source, /import \{ MAX_FILE_SIZE_MB \} from '@\/utils'/)+ assert.match(+ source,+ /\$t\('knowledgeBase\.pdfDocFormat', \{ size: MAX_FILE_SIZE_MB \}\)/,+ `${name}: pdf/doc hint`,+ )+ assert.match(+ source,+ /\$t\('knowledgeBase\.textMarkdownFormat', \{ size: MAX_FILE_SIZE_MB \}\)/,+ `${name}: text/markdown hint`,+ )+ }+})diff --git a/frontend/src/components/upload-mask.vue b/frontend/src/components/upload-mask.vueindex 6d1181499..6324e9b30 100644--- a/frontend/src/components/upload-mask.vue+++ b/frontend/src/components/upload-mask.vue@@ -1,13 +1,12 @@<script setup lang="ts">-import { useI18n } from 'vue-i18n'-const { t } = useI18n()+import { MAX_FILE_SIZE_MB } from '@/utils'</script><template><div class="mask"><img class="upload-mask-img" src="@/assets/img/upload-mask.svg" alt=""><span class="drag-txt">{{ $t('file.upload') }}</span>- <span class="drag-type-txt">{{ $t('knowledgeBase.pdfDocFormat') }}</span>- <span class="drag-type-txt">{{ $t('knowledgeBase.textMarkdownFormat') }}</span>+ <span class="drag-type-txt">{{ $t('knowledgeBase.pdfDocFormat', { size: MAX_FILE_SIZE_MB }) }}</span>+ <span class="drag-type-txt">{{ $t('knowledgeBase.textMarkdownFormat', { size: MAX_FILE_SIZE_MB }) }}</span></div></template><style scoped lang="less">diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 5499a2b7f..4b8485718 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -973,8 +973,8 @@ export default {statusDraft: 'Draft',noDescription: 'No description',emptyKnowledgeDragDrop: 'Knowledge is empty, drag and drop to upload',- pdfDocFormat: 'pdf, doc format files, max 10M',- textMarkdownFormat: 'text, markdown format files, max 200K',+ pdfDocFormat: 'pdf, doc format files, max {size}MB',+ textMarkdownFormat: 'text, markdown format files, max {size}MB',dragFileNotText: 'Please drag files instead of text or links',searchPlaceholder: 'Search knowledge bases...',docSearchPlaceholder: 'Search document names...',diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.tsindex 7e288fca3..9e00d8a43 100644--- a/frontend/src/i18n/locales/ja-JP.ts+++ b/frontend/src/i18n/locales/ja-JP.ts@@ -973,8 +973,8 @@ export default {statusDraft: '下書き',noDescription: '説明なし',emptyKnowledgeDragDrop: 'ナレッジがありません。ドラッグ&ドロップでアップロードできます',- pdfDocFormat: 'pdf、doc形式のファイル、最大10M',- textMarkdownFormat: 'text、markdown形式のファイル、最大200K',+ pdfDocFormat: 'pdf、doc形式のファイル、最大{size}MB',+ textMarkdownFormat: 'text、markdown形式のファイル、最大{size}MB',dragFileNotText: 'テキストやリンクではなくファイルをドラッグしてください',searchPlaceholder: 'ナレッジベースを検索...',docSearchPlaceholder: 'ドキュメント名を検索...',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex f3412fe8b..a5d1dc6fe 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -7370,8 +7370,8 @@ export default {statusDraft: '초안',noDescription: '설명 없음',emptyKnowledgeDragDrop: '지식이 비어 있음, 드래그 앤 드롭으로 업로드',- pdfDocFormat: 'pdf, doc 형식 파일, 최대 10MB',- textMarkdownFormat: 'text, markdown 형식 파일, 최대 200KB',+ pdfDocFormat: 'pdf, doc 형식 파일, 최대 {size}MB',+ textMarkdownFormat: 'text, markdown 형식 파일, 최대 {size}MB',dragFileNotText: '텍스트나 링크가 아닌 파일을 드래그하세요',searchPlaceholder: '지식베이스 검색...',docSearchPlaceholder: '문서 이름 검색...',diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex c11bf5d03..35fa2dd04 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -7370,8 +7370,8 @@ export default {statusDraft: 'Черновик',noDescription: 'Нет описания',emptyKnowledgeDragDrop: 'База знаний пуста, перетащите файлы для загрузки',- pdfDocFormat: 'Файлы pdf, doc формата, не более 10 МБ',- textMarkdownFormat: 'Файлы text, markdown формата, не более 200 КБ',+ pdfDocFormat: 'Файлы pdf, doc формата, не более {size} МБ',+ textMarkdownFormat: 'Файлы text, markdown формата, не более {size} МБ',dragFileNotText: 'Пожалуйста, перетащите файлы, а не текст или ссылки',searchPlaceholder: 'Поиск по базам знаний...',docSearchPlaceholder: 'Поиск документов...',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 5181662fd..36a09de5b 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -7372,8 +7372,8 @@ export default {statusDraft: '草稿',noDescription: '无描述',emptyKnowledgeDragDrop: '知识为空,拖放上传',- pdfDocFormat: 'pdf、doc 格式文件,不超过10M',- textMarkdownFormat: 'text、markdown格式文件,不超过200K',+ pdfDocFormat: 'pdf、doc 格式文件,不超过{size}M',+ textMarkdownFormat: 'text、markdown格式文件,不超过{size}M',dragFileNotText: '请拖拽文件而不是文本或链接',searchPlaceholder: '搜索知识库...',docSearchPlaceholder: '搜索文档名称...',diff --git a/frontend/src/i18n/locales/zh-TW.ts b/frontend/src/i18n/locales/zh-TW.tsindex 8c67f70a5..3c812777e 100644--- a/frontend/src/i18n/locales/zh-TW.ts+++ b/frontend/src/i18n/locales/zh-TW.ts@@ -7372,8 +7372,8 @@ export default {statusDraft: '草稿',noDescription: '無描述',emptyKnowledgeDragDrop: '知識為空,拖放上傳',- pdfDocFormat: 'pdf、doc 格式檔案,不超過10M',- textMarkdownFormat: 'text、markdown格式檔案,不超過200K',+ pdfDocFormat: 'pdf、doc 格式檔案,不超過{size}M',+ textMarkdownFormat: 'text、markdown格式檔案,不超過{size}M',dragFileNotText: '請拖曳檔案而不是文字或連結',searchPlaceholder: '搜尋知識庫...',docSearchPlaceholder: '搜尋檔案名稱...',