This commit is contained in:
2026-06-22 08:55:57 +08:00
parent dbb87823e8
commit 6ade6e8fa9
325 changed files with 41131 additions and 855 deletions
+15
View File
@@ -63,6 +63,21 @@ func (r *Registry) GetClient(ctx context.Context, id uuid.UUID) (LLMClient, erro
return c, nil
}
// GetEmbedder 返回该 endpoint 对应的 Embedder(OpenAI / Gemini 实现;Anthropic
// 客户端虽实现接口但 Embed 返回 ErrEmbeddingsUnsupported)。底层复用 GetClient
// 的缓存与构造,再做类型断言。endpoint 的 client 未实现 Embedder 时返回错误。
func (r *Registry) GetEmbedder(ctx context.Context, id uuid.UUID) (Embedder, error) {
c, err := r.GetClient(ctx, id)
if err != nil {
return nil, err
}
emb, ok := c.(Embedder)
if !ok {
return nil, fmt.Errorf("llm registry: endpoint %s provider %q does not support embeddings", id, c.Provider())
}
return emb, nil
}
// Invalidate 删除该 endpoint 的缓存条目。endpoint CRUD 后由 service 层调用。
func (r *Registry) Invalidate(id uuid.UUID) {
r.mu.Lock()