diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-11 08:21:33 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-11 08:21:33 +0300 |
| commit | 73dadb573f92dca310036e8793932e94277abd62 (patch) | |
| tree | f2def55cf07533400dda21babb759d077e7f899b | |
| parent | 8135a6b851b420597c22cfa5e58e6d69e894a00d (diff) | |
llm: add compile-time interface checks for all providers
Add the missing var _ Client / var _ Streamer compile-time satisfaction
check to anthropicClient, and clarify the existing assertion comments for
openAIClient, openRouterClient, ollamaClient (all Client+Streamer) and
youSearchClient (Client only; the You.com research API is non-streaming).
All providers use value receivers, so assertions use zero-value structs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| -rw-r--r-- | internal/llm/anthropic.go | 7 | ||||
| -rw-r--r-- | internal/llm/ollama.go | 3 | ||||
| -rw-r--r-- | internal/llm/openai.go | 3 | ||||
| -rw-r--r-- | internal/llm/openrouter.go | 3 | ||||
| -rw-r--r-- | internal/llm/yousearch.go | 4 |
5 files changed, 17 insertions, 3 deletions
diff --git a/internal/llm/anthropic.go b/internal/llm/anthropic.go index 00af17a..6ed808f 100644 --- a/internal/llm/anthropic.go +++ b/internal/llm/anthropic.go @@ -25,6 +25,13 @@ type anthropicClient struct { defaultTemperature *float64 } +// Ensure anthropicClient implements Client and Streamer. All of its methods use +// value receivers, so the assertions use a zero-value struct (not a pointer). +var ( + _ Client = anthropicClient{} + _ Streamer = anthropicClient{} +) + type anthropicChatRequest struct { Model string `json:"model"` Messages []anthropicMessage `json:"messages"` diff --git a/internal/llm/ollama.go b/internal/llm/ollama.go index 83823bc..92fece8 100644 --- a/internal/llm/ollama.go +++ b/internal/llm/ollama.go @@ -28,7 +28,8 @@ type ollamaClient struct { defaultTemperature *float64 } -// Ensure ollamaClient implements Client and Streamer. +// Ensure ollamaClient implements Client and Streamer. All of its methods use +// value receivers, so the assertions use a zero-value struct (not a pointer). var ( _ Client = ollamaClient{} _ Streamer = ollamaClient{} diff --git a/internal/llm/openai.go b/internal/llm/openai.go index 983723a..25696ce 100644 --- a/internal/llm/openai.go +++ b/internal/llm/openai.go @@ -25,7 +25,8 @@ type openAIClient struct { defaultTemperature *float64 } -// Ensure openAIClient implements Client and Streamer. +// Ensure openAIClient implements Client and Streamer. All of its methods use +// value receivers, so the assertions use a zero-value struct (not a pointer). var ( _ Client = openAIClient{} _ Streamer = openAIClient{} diff --git a/internal/llm/openrouter.go b/internal/llm/openrouter.go index 970ec29..567a2c0 100644 --- a/internal/llm/openrouter.go +++ b/internal/llm/openrouter.go @@ -22,7 +22,8 @@ type openRouterClient struct { defaultTemperature *float64 } -// Ensure openRouterClient implements Client and Streamer. +// Ensure openRouterClient implements Client and Streamer. All of its methods +// use value receivers, so the assertions use a zero-value struct (not a pointer). var ( _ Client = openRouterClient{} _ Streamer = openRouterClient{} diff --git a/internal/llm/yousearch.go b/internal/llm/yousearch.go index 66cfb35..8990c26 100644 --- a/internal/llm/yousearch.go +++ b/internal/llm/yousearch.go @@ -26,6 +26,10 @@ type youSearchClient struct { chatLogger logging.ChatLogger } +// Ensure youSearchClient implements Client. It does not implement Streamer +// because the You.com research API returns a single completed result rather +// than a token stream. Methods use value receivers, so the assertion uses a +// zero-value struct (not a pointer). var _ Client = youSearchClient{} type youSearchRequest struct { |
