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 -2
View File
@@ -9,8 +9,12 @@ import (
"github.com/anthropics/anthropic-sdk-go/option"
)
// Compile-time assertion: AnthropicClient must satisfy LLMClient.
var _ LLMClient = (*AnthropicClient)(nil)
// Compile-time assertion: AnthropicClient must satisfy LLMClient + Embedder
// (Embed returns ErrEmbeddingsUnsupported).
var (
_ LLMClient = (*AnthropicClient)(nil)
_ Embedder = (*AnthropicClient)(nil)
)
// AnthropicClient 通过官方 SDK 调用 Anthropic Messages API。
// baseURL 可改写以走 LiteLLM/OpenRouter 等代理。
@@ -152,3 +156,12 @@ func (c *AnthropicClient) CountTokens(ctx context.Context, modelID string, req R
}
return int(res.InputTokens), nil
}
// Embed is unsupported: Anthropic has no embeddings API. Embeddings must target
// an OpenAI-compatible or Gemini endpoint; callers degrade to keyword fallback.
func (c *AnthropicClient) Embed(context.Context, string, []string) ([][]float32, error) {
return nil, ErrEmbeddingsUnsupported
}
// EmbedDims is 0 since Anthropic produces no embeddings.
func (c *AnthropicClient) EmbedDims(string) int { return 0 }