Files
ai-agent/internal/ai/rag/index_storage_helpers.go
T
t 2bbf42b741 refactor(auth): delegate access control to be-system
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
2026-08-21 00:41:07 +08:00

25 lines
724 B
Go

package rag
import (
"context"
"fmt"
"log/slog"
"code.tczkiot.com/wlw/ai-agent/internal/ai/rag/vectordb"
)
func (s *index) ensureCollection(ctx context.Context, provider vectordb.Provider, collectionName string, dimension int) error {
collectionInfo, err := provider.GetCollection(ctx, collectionName)
if err == nil && collectionInfo != nil {
return nil
}
if dimension <= 0 {
return fmt.Errorf("invalid embedding dimension: %d", dimension)
}
if err := provider.CreateCollection(ctx, collectionName, dimension); err != nil {
return fmt.Errorf("failed to create collection: %w", err)
}
slog.Info("Created collection for knowledge base", "collection", collectionName, "dimension", dimension)
return nil
}