From 38646001e670e197df893ef7894b56b421f4050f Mon Sep 17 00:00:00 2001 From: root <953994191@qq.com> Date: Tue, 21 Apr 2026 23:15:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/backend/Dockerfile | 11 +++++------ test/test_backend.py | 8 ++++---- test/test_rag_indexer_result.py | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile index 0084353..aeb8c74 100644 --- a/docker/backend/Dockerfile +++ b/docker/backend/Dockerfile @@ -59,13 +59,12 @@ ENV DEBUG=false # 安装依赖 # ============================================================================= # 复制本地模型文件到镜像(如果有) -COPY docker/models/*.whl /tmp/models/ 2>/dev/null || true +# 注意:docker/models/ 目录需要在构建上下文中存在 +COPY docker/models/ /tmp/models/ -# 安装本地模型 wheel(如果有) -RUN if [ -n "$(ls -A /tmp/models/ 2>/dev/null)" ]; then \ - pip install --no-cache-dir /tmp/models/*.whl && \ - rm -rf /tmp/models; \ - fi +# 安装本地模型 wheel(如果有 .whl 文件) +RUN find /tmp/models -name "*.whl" -type f 2>/dev/null | head -1 | xargs -r pip install --no-cache-dir && \ + rm -rf /tmp/models # 设置 pip 国内镜像源 RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple diff --git a/test/test_backend.py b/test/test_backend.py index d95a71a..19af1ad 100644 --- a/test/test_backend.py +++ b/test/test_backend.py @@ -74,14 +74,14 @@ async def test_tool_calling(agent_service): print(f"使用 user_id: {user_id}") # 发送需要 RAG 搜索的问题 - print("\n发送消息: '请告诉我,打虎英雄是谁?'") + print("\n发送消息: '请告诉我,黄双银在魔王大陆的故事?'") result = await agent_service.process_message( - "请告诉我,打虎英雄是谁?", thread_id, "local", user_id + "请告诉我,黄双银在魔王大陆的故事?", thread_id, "local", user_id ) print(f"回复: {result['reply'][:200]}...") - # 检查是否调用了 RAG 工具(回复中会有水浒传相关内容) - if "武松" in result['reply'] or "李忠" in result['reply'] or "水浒传" in result['reply']: + # 检查是否调用了 RAG 工具(回复中会有黄双银相关内容) + if "黄双银" in result['reply']: print("\n✅ 工具调用测试通过!") return True else: diff --git a/test/test_rag_indexer_result.py b/test/test_rag_indexer_result.py index 771a429..7c9ea41 100644 --- a/test/test_rag_indexer_result.py +++ b/test/test_rag_indexer_result.py @@ -20,14 +20,14 @@ async def test_index_builder(): # 创建 IndexBuilder 实例 builder = IndexBuilder( - collection_name="test_collection", + collection_name="rag_documents", splitter_type=SplitterType.PARENT_CHILD, parent_chunk_size=1000, child_chunk_size=200 ) # 测试文档路径 - test_file = os.path.join(os.path.dirname(__file__), "..", "data", "user_docs", "a.txt") + test_file = os.path.join(os.path.dirname(__file__), "..", "data", "user_docs", "doublestory.txt") if os.path.exists(test_file): # 构建索引