ProcessPendingEmbeddings 处理待向量化的分块
(eid int64, batchSize int)
| 216 | |
| 217 | // ProcessPendingEmbeddings 处理待向量化的分块 |
| 218 | func (s *EmbeddingService) ProcessPendingEmbeddings(eid int64, batchSize int) error { |
| 219 | // 获取待处理的分块 |
| 220 | chunks, err := model.GetPendingEmbeddingChunks(eid, batchSize) |
| 221 | if err != nil { |
| 222 | return fmt.Errorf("获取待处理分块失败: %v", err) |
| 223 | } |
| 224 | |
| 225 | if len(chunks) == 0 { |
| 226 | return nil |
| 227 | } |
| 228 | |
| 229 | // 逐个处理 |
| 230 | for _, chunk := range chunks { |
| 231 | err := s.ProcessChunkEmbedding(eid, chunk.ID) |
| 232 | if err != nil { |
| 233 | fmt.Printf("处理分块 %d 向量化失败: %v\n", chunk.ID, err) |
| 234 | continue |
| 235 | } |
| 236 | |
| 237 | // 添加延迟避免API限流 |
| 238 | time.Sleep(100 * time.Millisecond) |
| 239 | } |
| 240 | |
| 241 | return nil |
| 242 | } |
| 243 | |
| 244 | // callEmbeddingAPIWithStop 调用embedding API (兼容旧接口) - 支持停止信号检查 |
| 245 | func (s *EmbeddingService) callEmbeddingAPIWithStop(content string, channel *model.Channel, config *ChunkConfig, libraryID, fileID int64) ([]float64, error) { |
nothing calls this directly
no test coverage detected