xinli/诊断上传卡住问题.md
2025-12-19 14:03:43 +08:00

108 lines
2.7 KiB
Markdown
Raw 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.

# 诊断文档上传卡住问题
## 问题现象
- 界面显示AI服务已连接、向量存储正常
- 但上传文档时一直加载,无法完成
## 可能原因
### 1. 向量化超时
**症状**:上传卡在向量化步骤
**原因**AI服务响应慢或模型未加载
### 2. ChromaDB连接问题
**症状**:向量化完成但存储失败
**原因**ChromaDB服务未启动或连接超时
### 3. 文件太大
**症状**:大文件处理时间长
**原因**:分块数量多,向量化耗时
## 快速诊断步骤
### 步骤1查看后端日志
上传文档时,观察后端控制台输出,找到最后一条日志:
```
✓ 正常流程:
Uploading document: xxx.txt
Parsed document: 1234 characters
Split document into 5 chunks
Starting vectorization for 5 chunks... ← 如果卡在这里,是向量化问题
Successfully generated 5 embeddings ← 如果卡在这里,是存储问题
Stored 5 chunks to ChromaDB
Document uploaded successfully
✗ 如果卡住,会停在某一步不动
```
### 步骤2检查服务状态
运行:`检查RAG服务状态.bat`
或手动检查:
```bash
# 检查Ollama
curl http://localhost:11434/api/tags
# 检查ChromaDB如果使用
curl http://localhost:8000/api/v1/heartbeat
```
## 解决方案
### 方案A使用SimpleVectorStore推荐最快
**优点**:无需安装额外服务,内存存储,速度快
**缺点**:重启后数据丢失(可配置持久化)
**操作**
1. 确认`useSimpleStore = true`(代码中已默认)
2. 重启后端服务
3. 测试上传
### 方案B安装ChromaDB生产环境推荐
**优点**:数据持久化,性能好
**缺点**需要安装Python和ChromaDB
**快速安装**
```bash
# 1. 安装ChromaDB
pip install chromadb
# 2. 启动服务
chroma run --host localhost --port 8000
# 3. 验证
curl http://localhost:8000/api/v1/heartbeat
```
### 方案C增加超时时间
如果服务正常但处理慢,增加超时:
修改`RagProperties.java`
```java
private int connectTimeout = 60; // 改为60秒
private int readTimeout = 600; // 改为600秒
```
## 当前最可能的问题
根据你的描述"服务都正常"但"没有ChromaDB"系统应该已经在使用SimpleVectorStore。
**上传卡住最可能的原因是**
1. 向量化服务Ollama/OpenAI响应慢
2. 后端没有重启,还在使用旧代码
## 立即尝试
### 1. 重启后端服务
确保最新代码生效
### 2. 上传小文件测试
先上传一个很小的txt文件几行文字看是否能成功
### 3. 查看后端日志
找到卡住的具体位置
### 4. 告诉我日志内容
把后端日志最后几行发给我,我帮你定位问题