MCPcopy Create free account
hub / github.com/53AI/53AIHub / ProcessPendingEmbeddings

Method ProcessPendingEmbeddings

api/service/rag/embedding.go:218–242  ·  view source on GitHub ↗

ProcessPendingEmbeddings 处理待向量化的分块

(eid int64, batchSize int)

Source from the content-addressed store, hash-verified

216
217// ProcessPendingEmbeddings 处理待向量化的分块
218func (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 (兼容旧接口) - 支持停止信号检查
245func (s *EmbeddingService) callEmbeddingAPIWithStop(content string, channel *model.Channel, config *ChunkConfig, libraryID, fileID int64) ([]float64, error) {

Callers

nothing calls this directly

Calls 3

ProcessChunkEmbeddingMethod · 0.95
ErrorfMethod · 0.80
PrintfMethod · 0.80

Tested by

no test coverage detected