mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 13:23:16 +08:00
* 知识库支持行式 json 文件 如果要使用 json 文件, 需要 `conda install jq`(windows 下 pip install jq 会失败) 开发者: 删除 CustomJsonLoader,使用 langchain 自带的 JsonLoader 处理 json 文件,添加 JsonLinesLoader 处理 jsonl 文件。 * 知识库支持 .epub, .xlsx, .xlsd, .ipynb, .odt, .py, .srt, .toml, .doc, .ppt 文件 为 .eml, .msg, .rst, .rtf, .tsv, .docx, .xml, .pptx 指定专用加载器
36 lines
779 B
Python
36 lines
779 B
Python
from server.knowledge_base.kb_service.faiss_kb_service import FaissKBService
|
|
from server.knowledge_base.migrate import create_tables
|
|
from server.knowledge_base.utils import KnowledgeFile
|
|
|
|
|
|
kbService = FaissKBService("test")
|
|
test_kb_name = "test"
|
|
test_file_name = "README.md"
|
|
testKnowledgeFile = KnowledgeFile(test_file_name, test_kb_name)
|
|
search_content = "如何启动api服务"
|
|
|
|
|
|
def test_init():
|
|
create_tables()
|
|
|
|
|
|
def test_create_db():
|
|
assert kbService.create_kb()
|
|
|
|
|
|
def test_add_doc():
|
|
assert kbService.add_doc(testKnowledgeFile)
|
|
|
|
|
|
def test_search_db():
|
|
result = kbService.search_docs(search_content)
|
|
assert len(result) > 0
|
|
|
|
|
|
def test_delete_doc():
|
|
assert kbService.delete_doc(testKnowledgeFile)
|
|
|
|
|
|
def test_delete_db():
|
|
assert kbService.drop_kb()
|