mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-25 17:22:55 +00:00
fix: Download template error
--bug=1051908 --user=王孝刚 【知识库】导出的文档打开后里面为错误日志,无文档内容,导出的压缩包不能解压 https://www.tapd.cn/57709429/s/1650087
This commit is contained in:
parent
5ebcad7cde
commit
4610be9745
|
|
@ -23,7 +23,6 @@ from django.db import transaction
|
|||
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 drf_yasg import openapi
|
||||
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
|
||||
from rest_framework import serializers
|
||||
|
|
@ -65,6 +64,8 @@ from embedding.task.embedding import embedding_by_document, delete_embedding_by_
|
|||
embedding_by_document_list
|
||||
from setting.models import Model
|
||||
from smartdoc.conf import PROJECT_DIR
|
||||
from django.utils.translation import gettext_lazy as _, gettext, to_locale
|
||||
from django.utils.translation import get_language
|
||||
|
||||
parse_qa_handle_list = [XlsParseQAHandle(), CsvParseQAHandle(), XlsxParseQAHandle(), ZipParseQAHandle()]
|
||||
parse_table_handle_list = [CsvSplitTableHandle(), XlsSplitTableHandle(), XlsxSplitTableHandle()]
|
||||
|
|
@ -240,15 +241,15 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
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 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
|
|
@ -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優勢"
|
||||
|
Binary file not shown.
Binary file not shown.
|
|
@ -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
|
||||
|
Binary file not shown.
|
|
@ -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
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue