2.4 KiB
2.4 KiB
连接重置问题解决方案
问题描述
- OPTIONS 请求成功(200 OK)
- POST 请求失败(ERR_CONNECTION_RESET)
这表明 CORS 配置已经生效,但是实际处理请求时服务崩溃了。
可能的原因和解决方案
1. 检查 Neo4j 数据库
graph-rag-agent 需要 Neo4j 数据库运行:
# 检查 Neo4j 是否运行
sudo systemctl status neo4j
# 如果未运行,启动它
sudo systemctl start neo4j
# 或使用 Docker
docker ps | grep neo4j
2. 检查 graph-rag-agent 的配置
确保配置文件存在:
cd ~/graph-rag-agent
ls -la config/
# 应该有 settings.py 或类似的配置文件
3. 查看 graph-rag-agent 的错误日志
在运行 graph-rag-agent 的终端中查看错误信息。常见错误:
-
Neo4j 连接失败:
neo4j.exceptions.ServiceUnavailable: Unable to connect to localhost:7687解决:启动 Neo4j 数据库
-
缺少 embedding 模型:
FileNotFoundError: [Errno 2] No such file or directory: 'path/to/embeddings'解决:确保已下载并配置了 embedding 模型
-
Agent 初始化失败:
KeyError: 'naive_rag_agent'解决:检查 agent 配置和初始化
4. 简化测试
创建一个最小测试来确认服务基本功能:
# 测试根路径
curl http://localhost:8000/
# 测试文档
curl http://localhost:8000/docs
5. 环境变量检查
graph-rag-agent 可能需要某些环境变量:
# 检查是否需要 OpenAI API Key
export OPENAI_API_KEY="your-key-here"
# 检查 Neo4j 连接配置
export NEO4J_URI="bolt://localhost:7687"
export NEO4J_USER="neo4j"
export NEO4J_PASSWORD="your-password"
6. 依赖检查
确保所有依赖都已安装:
cd ~/graph-rag-agent
pip install -r requirements.txt
7. 使用调试模式启动
cd ~/graph-rag-agent
python -m uvicorn server.main:app --reload --log-level debug
临时解决方案
如果上述方法都不能解决问题,可以:
- 使用模拟响应:在前端创建一个模拟的响应来测试前端功能
- 检查 graph-rag-agent 的 README:查看是否有特殊的启动要求
- 查看 graph-rag-agent 的测试代码:了解正确的使用方式
测试命令
使用提供的测试脚本:
cd ~/yundage-backserver-test
./test-curl.sh
观察输出,特别是错误信息。