diff --git a/apps/dataset/serializers/document_serializers.py b/apps/dataset/serializers/document_serializers.py index 2a664882850..dc2d41b5bee 100644 --- a/apps/dataset/serializers/document_serializers.py +++ b/apps/dataset/serializers/document_serializers.py @@ -23,7 +23,8 @@ from django.db.models import QuerySet, Count from django.db.models.functions import Substr, Reverse from django.http import HttpResponse -from django.utils.translation import gettext_lazy as _, gettext +from django.utils.translation import gettext_lazy as _, gettext, to_locale +from django.utils.translation import get_language from drf_yasg import openapi from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE from rest_framework import serializers @@ -240,15 +241,15 @@ def get_request_params_api(): def export(self, with_valid=True): if with_valid: self.is_valid(raise_exception=True) - + language = get_language() if self.data.get('type') == 'csv': - file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', 'csv_template.csv'), "rb") + file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'csv_template_{to_locale(language)}.csv'), "rb") content = file.read() file.close() return HttpResponse(content, status=200, headers={'Content-Type': 'text/cxv', 'Content-Disposition': 'attachment; filename="csv_template.csv"'}) elif self.data.get('type') == 'excel': - file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', 'excel_template.xlsx'), "rb") + file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'csv_template_{to_locale(language)}.xlsx'), "rb") content = file.read() file.close() return HttpResponse(content, status=200, headers={'Content-Type': 'application/vnd.ms-excel', @@ -257,16 +258,18 @@ def export(self, with_valid=True): def table_export(self, with_valid=True): if with_valid: self.is_valid(raise_exception=True) - + language = get_language() if self.data.get('type') == 'csv': - file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', _('MaxKB table template.csv')), - "rb") + file = open( + os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'table_template_{to_locale(language)}.csv'), + "rb") content = file.read() file.close() return HttpResponse(content, status=200, headers={'Content-Type': 'text/cxv', 'Content-Disposition': 'attachment; filename="csv_template.csv"'}) elif self.data.get('type') == 'excel': - file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', _('MaxKB table template.xlsx')), + file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', + f'table_template_{to_locale(language)}.xlsx'), "rb") content = file.read() file.close() diff --git a/apps/dataset/template/csv_template_en.csv b/apps/dataset/template/csv_template_en.csv new file mode 100644 index 00000000000..99c2711b2e5 --- /dev/null +++ b/apps/dataset/template/csv_template_en.csv @@ -0,0 +1,8 @@ +Section title (optional), section content (required, question answer, no more than 4096 characters)), question (optional, one per line in the cell) +MaxKB product introduction, "MaxKB is a knowledge base question and answer system based on the LLM large language model. MaxKB = Max Knowledge Base aims to become the most powerful brain of the enterprise. +Out-of-the-box: supports direct uploading of documents, automatic crawling of online documents, automatic text splitting and vectorization, and a good intelligent Q&A interactive experience; +Seamless embedding: supports rapid embedding into third-party business systems with zero coding; +Multi-model support: Supports docking with mainstream large models, including Ollama local private large models (such as Llama 2, Llama 3, qwen), Tongyi Qianwen, OpenAI, Azure OpenAI, Kimi, Zhipu AI, iFlytek Spark and Baidu Qianfan Large models etc. ","What is MaxKB? +MaxKB product introduction +Large language model supported by MaxKB +MaxKB advantages" \ No newline at end of file diff --git a/apps/dataset/template/csv_template.csv b/apps/dataset/template/csv_template_zh.csv similarity index 100% rename from apps/dataset/template/csv_template.csv rename to apps/dataset/template/csv_template_zh.csv diff --git a/apps/dataset/template/csv_template_zh_Hant.csv b/apps/dataset/template/csv_template_zh_Hant.csv new file mode 100644 index 00000000000..5b675fee6b4 --- /dev/null +++ b/apps/dataset/template/csv_template_zh_Hant.csv @@ -0,0 +1,8 @@ +分段標題(選填),分段內容(必填,問題答案,最長不超過4096個字元)),問題(選填,單元格內一行一個) +MaxKB產品介紹,"MaxKB 是一款基於 LLM 大語言模型的知識庫問答系統。MaxKB = Max Knowledge Base,旨在成為企業的最強大大腦。 +開箱即用:支援直接上傳文檔、自動爬取線上文檔,支援文字自動分割、向量化,智慧問答互動體驗好; +無縫嵌入:支援零編碼快速嵌入到第三方業務系統; +多模型支援:支持對接主流的大模型,包括Ollama 本地私有大模型(如Llama 2、Llama 3、qwen)、通義千問、OpenAI、Azure OpenAI、Kimi、智譜AI、訊飛星火和百度千帆大模型等。 ","MaxKB是什麼? +MaxKB產品介紹 +MaxKB支援的大語言模型 +MaxKB優勢" \ No newline at end of file diff --git a/apps/dataset/template/excel_template_en.xlsx b/apps/dataset/template/excel_template_en.xlsx new file mode 100644 index 00000000000..ded0c2daccf Binary files /dev/null and b/apps/dataset/template/excel_template_en.xlsx differ diff --git a/apps/dataset/template/excel_template.xlsx b/apps/dataset/template/excel_template_zh.xlsx similarity index 100% rename from apps/dataset/template/excel_template.xlsx rename to apps/dataset/template/excel_template_zh.xlsx diff --git a/apps/dataset/template/excel_template_zh_Hant.xlsx b/apps/dataset/template/excel_template_zh_Hant.xlsx new file mode 100644 index 00000000000..eb6ec2d441d Binary files /dev/null and b/apps/dataset/template/excel_template_zh_Hant.xlsx differ diff --git a/apps/dataset/template/table_template_en.csv b/apps/dataset/template/table_template_en.csv new file mode 100644 index 00000000000..d98e21c1698 --- /dev/null +++ b/apps/dataset/template/table_template_en.csv @@ -0,0 +1,13 @@ +Position, reimbursement type, first-tier city reimbursement standard (yuan), second-tier city reimbursement standard (yuan), third-tier city reimbursement standard (yuan) +Ordinary employees, accommodation expenses, 500, 400, 300 +Department head, accommodation fee, 600, 500, 400 +Department director, accommodation fee, 700, 600, 500 +Regional general manager, accommodation fee, 800, 700, 600 +Ordinary employees, food expenses, 50, 40, 30 +Department head, food expenses, 50, 40, 30 +Department director, food expenses, 50, 40, 30 +Regional general manager, food expenses, 50, 40, 30 +Ordinary employees, transportation expenses, 50, 40, 30 +Department head, transportation expenses, 50, 40, 30 +Department director, transportation expenses, 50, 40, 30 +Regional general manager, transportation expenses, 50, 40, 30 \ No newline at end of file diff --git a/apps/dataset/template/table_template_en.xlsx b/apps/dataset/template/table_template_en.xlsx new file mode 100644 index 00000000000..1e445822664 Binary files /dev/null and b/apps/dataset/template/table_template_en.xlsx differ diff --git "a/apps/dataset/template/MaxKB\350\241\250\346\240\274\346\250\241\346\235\277.csv" b/apps/dataset/template/table_template_zh.csv similarity index 100% rename from "apps/dataset/template/MaxKB\350\241\250\346\240\274\346\250\241\346\235\277.csv" rename to apps/dataset/template/table_template_zh.csv diff --git "a/apps/dataset/template/MaxKB\350\241\250\346\240\274\346\250\241\346\235\277.xlsx" b/apps/dataset/template/table_template_zh.xlsx similarity index 100% rename from "apps/dataset/template/MaxKB\350\241\250\346\240\274\346\250\241\346\235\277.xlsx" rename to apps/dataset/template/table_template_zh.xlsx diff --git a/apps/dataset/template/table_template_zh_Hant.csv b/apps/dataset/template/table_template_zh_Hant.csv new file mode 100644 index 00000000000..2e30ab49c33 --- /dev/null +++ b/apps/dataset/template/table_template_zh_Hant.csv @@ -0,0 +1,13 @@ +職務,報銷類型,一線城市報銷標準(元),二線城市報銷標準(元),三線城市報銷標準(元) +普通員工,住宿費,500,400,300 +部門主管,住宿費,600,500,400 +部門總監,住宿費,700,600,500 +區域總經理,住宿費,800,700,600 +普通員工,伙食費,50,40,30 +部門主管,伙食費,50,40,30 +部門總監,伙食費,50,40,30 +區域總經理,伙食費,50,40,30 +普通員工,交通費,50,40,30 +部門主管,交通費,50,40,30 +部門總監,交通費,50,40,30 +區域總經理,交通費,50,40,30 \ No newline at end of file diff --git a/apps/dataset/template/table_template_zh_Hant.xlsx b/apps/dataset/template/table_template_zh_Hant.xlsx new file mode 100644 index 00000000000..53f34e4ed9d Binary files /dev/null and b/apps/dataset/template/table_template_zh_Hant.xlsx differ