mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-17 11:07:11 +08:00
feat(knowledge): add document creation and import
This commit is contained in:
@@ -35,7 +35,7 @@ class KnowledgeService:
|
||||
IMPORT_EXTENSIONS = {".md", ".txt"}
|
||||
MAX_IMPORT_FILES = 100
|
||||
MAX_IMPORT_FILE_SIZE = 10 * 1024 * 1024
|
||||
MAX_IMPORT_TOTAL_SIZE = 50 * 1024 * 1024
|
||||
MAX_IMPORT_TOTAL_SIZE = 200 * 1024 * 1024
|
||||
|
||||
def __init__(self, workspace_root: str, memory_manager=None):
|
||||
self.workspace_root = os.path.abspath(workspace_root)
|
||||
|
||||
@@ -7547,7 +7547,7 @@ let _knowledgeCurrentFile = null;
|
||||
let _knowledgeGraphLoaded = false;
|
||||
const KNOWLEDGE_IMPORT_MAX_FILES = 100;
|
||||
const KNOWLEDGE_IMPORT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
||||
const KNOWLEDGE_IMPORT_MAX_TOTAL_SIZE = 50 * 1024 * 1024;
|
||||
const KNOWLEDGE_IMPORT_MAX_TOTAL_SIZE = 200 * 1024 * 1024;
|
||||
|
||||
function loadKnowledgeView() {
|
||||
// Reset to docs tab
|
||||
@@ -7959,7 +7959,7 @@ function validateKnowledgeImportFiles(files) {
|
||||
}
|
||||
}
|
||||
if (total > KNOWLEDGE_IMPORT_MAX_TOTAL_SIZE) {
|
||||
return currentLang === 'zh' ? '单次导入总大小不能超过 50MB' : 'Total import size cannot exceed 50MB';
|
||||
return currentLang === 'zh' ? '单次导入总大小不能超过 200MB' : 'Total import size cannot exceed 200MB';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -280,6 +280,7 @@ def test_import_documents_skip_overwrite_and_failures(tmp_path):
|
||||
def test_import_documents_rejects_large_files_and_batches(tmp_path):
|
||||
svc, manager = service(tmp_path)
|
||||
(tmp_path / "knowledge/notes").mkdir()
|
||||
assert svc.MAX_IMPORT_TOTAL_SIZE == 200 * 1024 * 1024
|
||||
|
||||
too_large = svc.dispatch("import_documents", {
|
||||
"target_category": "notes",
|
||||
|
||||
@@ -114,6 +114,7 @@ def test_knowledge_import_handler_delegates_to_dispatch(tmp_path):
|
||||
def test_knowledge_import_handler_rejects_large_content_length(tmp_path):
|
||||
from channel.web.web_channel import KnowledgeImportHandler
|
||||
from agent.knowledge.service import KnowledgeService
|
||||
assert KnowledgeService.MAX_IMPORT_TOTAL_SIZE == 200 * 1024 * 1024
|
||||
|
||||
with patch("channel.web.web_channel._require_auth"), \
|
||||
patch("channel.web.web_channel.web.header"), \
|
||||
|
||||
Reference in New Issue
Block a user