From 73dadb573f92dca310036e8793932e94277abd62 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 11 Jun 2026 08:21:33 +0300 Subject: 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 --- internal/llm/anthropic.go | 7 +++++++ internal/llm/ollama.go | 3 ++- internal/llm/openai.go | 3 ++- internal/llm/openrouter.go | 3 ++- 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 { -- cgit v1.2.3