xinli/Archive/test-rag-system.bat
2026-01-30 16:23:31 +08:00

107 lines
3.1 KiB
Batchfile
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul
echo ========================================
echo RAG知识库系统 - 自动化测试脚本
echo ========================================
echo.
set BASE_URL=http://localhost:8080
REM 检查服务是否运行
echo [1/8] 检查系统健康状态...
curl -s %BASE_URL%/psychology/rag-test/health >nul 2>&1
if errorlevel 1 (
echo [失败] 系统未启动请先启动Spring Boot应用
pause
exit /b 1
)
echo [成功] 系统运行正常
echo.
REM 测试向量化
echo [2/8] 测试向量化功能...
curl -s -X POST "%BASE_URL%/psychology/rag-test/test-embedding" ^
-H "Content-Type: application/x-www-form-urlencoded" ^
-d "text=这是一个测试文本" | findstr "embedding_dimension" >nul
if errorlevel 1 (
echo [失败] 向量化测试失败
) else (
echo [成功] 向量化功能正常
)
echo.
REM 测试文本生成
echo [3/8] 测试文本生成功能...
curl -s -X POST "%BASE_URL%/psychology/rag-test/test-generation" ^
-H "Content-Type: application/x-www-form-urlencoded" ^
-d "prompt=什么是心理学?" | findstr "response" >nul
if errorlevel 1 (
echo [失败] 文本生成测试失败
) else (
echo [成功] 文本生成功能正常
)
echo.
REM 测试ChromaDB
echo [4/8] 测试ChromaDB存储和查询...
curl -s -X POST "%BASE_URL%/psychology/rag-test/test-chromadb" | findstr "query_results" >nul
if errorlevel 1 (
echo [失败] ChromaDB测试失败
) else (
echo [成功] ChromaDB功能正常
)
echo.
REM 创建测试文档
echo [5/8] 创建测试文档...
echo 心理学基础知识 > test_doc.txt
echo. >> test_doc.txt
echo 人格心理学是研究个体在不同情境下表现出的稳定行为模式的学科。 >> test_doc.txt
echo 主要理论包括特质理论、精神分析理论和人本主义理论。 >> test_doc.txt
echo. >> test_doc.txt
echo 认知心理学关注人类的思维过程,包括注意、记忆、语言和问题解决。 >> test_doc.txt
echo [成功] 测试文档已创建: test_doc.txt
echo.
REM 测试文档上传
echo [6/8] 测试文档上传功能...
curl -s -X POST "%BASE_URL%/psychology/knowledge/upload" ^
-F "file=@test_doc.txt" ^
-F "category=综合心理学" | findstr "doc_id" >nul
if errorlevel 1 (
echo [失败] 文档上传测试失败
) else (
echo [成功] 文档上传功能正常
)
echo.
REM 等待处理完成
echo [7/8] 等待文档处理完成...
timeout /t 3 /nobreak >nul
echo [成功] 文档处理完成
echo.
REM 测试智能问答
echo [8/8] 测试智能问答功能...
curl -s -X POST "%BASE_URL%/psychology/ai/chat" ^
-H "Content-Type: application/json" ^
-d "{\"question\":\"什么是人格心理学?\",\"context\":\"\"}" | findstr "content" >nul
if errorlevel 1 (
echo [失败] 智能问答测试失败
) else (
echo [成功] 智能问答功能正常
)
echo.
echo ========================================
echo 测试完成!
echo ========================================
echo.
echo 详细测试结果请查看上方输出
echo 如需查看完整响应请手动运行curl命令
echo.
echo 清理测试文件...
del test_doc.txt >nul 2>&1
echo.
pause