feat: enhance knowledge search by resolving embedding model keys

- Introduced a new method to resolve embedding model IDs to their actual identity keys (name + endpoint), enabling optimal grouping of knowledge bases across different tenants.
- Updated the concurrent search functionality to utilize the resolved model keys, improving the efficiency of query embedding computations.
- Refactored search target grouping to reduce redundant API calls and enhance performance during hybrid searches.

These changes significantly improve the knowledge search process by ensuring that embeddings are computed efficiently and reused across multiple knowledge bases sharing the same underlying model.
This commit is contained in:
wizardchen
2026-03-13 20:54:25 +08:00
parent fc92b494b0
commit 9face5920b
4 changed files with 80 additions and 47 deletions
@@ -98,6 +98,12 @@ type KnowledgeBaseService interface {
// and reuse embeddings across multiple KBs that share the same model.
GetQueryEmbedding(ctx context.Context, kbID string, queryText string) ([]float32, error)
// ResolveEmbeddingModelKeys resolves embedding model IDs to their actual
// model identity key (name + endpoint). KBs using the same underlying model
// across different tenants will share the same key, enabling optimal grouping.
// Returns a map from KB ID to model identity key string.
ResolveEmbeddingModelKeys(ctx context.Context, kbs []*types.KnowledgeBase) map[string]string
// CopyKnowledgeBase copies a knowledge base
// Parameters:
// - ctx: Context information