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

Function NewEntityVectorService

api/service/rag/entity_vector.go:20–39  ·  view source on GitHub ↗
(db *gorm.DB)

Source from the content-addressed store, hash-verified

18}
19
20func NewEntityVectorService(db *gorm.DB) *EntityVectorService {
21 config := vectorstore.LoadFromEnv()
22 store, err := vectorstore.NewVectorStore(config)
23 if err != nil {
24 logger.SysLogf("创建向量存储失败: %v", err)
25 store = nil
26 }
27 if store != nil {
28 ctx := context.Background()
29 if err := store.Connect(ctx); err != nil {
30 logger.SysLogf("连接向量存储失败: %v", err)
31 store = nil
32 }
33 }
34 return &EntityVectorService{
35 db: db,
36 vectorDB: store,
37 embedding: NewEmbeddingService(db),
38 }
39}
40
41func (s *EntityVectorService) IndexEntity(eid int64, entity *model.Entity) error {
42 if entity == nil || entity.ID <= 0 {

Calls 2

ConnectMethod · 0.95
NewEmbeddingServiceFunction · 0.85

Tested by

no test coverage detected