feat: 功能验证

This commit is contained in:
李如威 2025-12-22 14:46:57 +08:00
parent 2e2082808a
commit d815416dda
4 changed files with 40 additions and 12 deletions

View File

@ -1,3 +1,19 @@
LOGGER_LEVEL=DEBUG
VERSION=1.0.0 VERSION=1.0.0
HOST=0.0.0.0 HOST=0.0.0.0
PORT=8011 PORT=8011
# LLM_API_KEY=sk-local-827ccb0eea8a706c4c34a16891f84e7b
# LLM_API_HOST=http://localhost:8022/v1
# LLM_MODEL=Qwen2.5
LLM_API_KEY=sk-390feb24-daee-11f0-a581-0242ac150003
LLM_API_HOST=http://58.214.239.10:18080/app-2512170147-llm/v1
LLM_MODEL=Qwen3-30B
EMBEDDING_API_KEY=sk-local-827ccb0eea8a706c4c34a16891f84e7b
EMBEDDING_API_HOST=http://localhost:8023/v1
EMBEDDING_MODEL=Qwen3-Embedding
EMBEDDING_DIMS=1024
ES_HOST=http://localhost
ES_PORT=9210
ES_USER=elastic
ES_PASSWORD=12345

View File

@ -25,5 +25,21 @@ GET /test_kb/_search
] ]
} }
GET /test_kb_1/_search
{
"size": 5,
"query": {
"match": {
"content": "美猴王"
}
},
"_source": [
"title",
"content",
"type",
"created_at"
]
}
// //
// DELETE /test_kb // DELETE /test_kb

View File

@ -183,10 +183,7 @@ def rag_user_prompt(query: str, documents: list[dict]) -> str:
用户问题: {query} 用户问题: {query}
回答要求: 回答要求:
1. 列出完整列表 一到两句话回复
2. 引用文档原文时文档 i 原文: 标注
3. 每条用编号列出
4. 如果文档中没有相关信息请直接回复: "文档未提供相关信息"
""" """
logger.debug(prompt) logger.debug(prompt)
return prompt return prompt

View File

@ -14,17 +14,16 @@ async def test_embedding():
logger.debug("file to es") logger.debug("file to es")
shared = { shared = {
"files": [ "./files/山海经01.txt"], "files": [ "./files/西游记.txt"],
"documents": [], # [{text, file_name, file_type, uuid, embedding}] "documents": [], # [{text, file_name, file_type, uuid, embedding}]
"index": "test_kb", "index": "test_kb_1",
} }
readNode = nodes.ReadDocumentsNode() readNode = nodes.ReadDocumentsNode()
chunkNode = nodes.ChunkDocumentsNode() chunkNode = nodes.ChunkDocumentsNode()
embeddingNode = nodes.EmbeddingDocumentsNode() embeddingNode = nodes.EmbeddingDocumentsNode()
writeToESNode = nodes.WriteDocumentsToESNode() writeToESNode = nodes.WriteDocumentsToESNode()
readNode >> chunkNode >> embeddingNode readNode >> chunkNode >> embeddingNode >> writeToESNode
# >> writeToESNode
flow = AsyncFlow(readNode) flow = AsyncFlow(readNode)
await flow.run_async(shared) await flow.run_async(shared)
@ -42,9 +41,9 @@ async def test_search():
logger.debug("search from es") logger.debug("search from es")
shared = { shared = {
"text": "哪里盛产金属矿物", "text": "哪里盛产矿石",
"index": "test_kb", "index": "test_kb",
"top_k": 1, "top_k": 5,
"results": [], # [{es_id, doc_id, title, type, created_at, score, content}] "results": [], # [{es_id, doc_id, title, type, created_at, score, content}]
} }