Replace Qwen provider with LiteLLM and OpenRouter aggregators
Adding one bespoke provider package per vendor doesn't scale. LiteLLM proxy and OpenRouter both speak the OpenAI chat-completions wire format and each front dozens-to-hundreds of underlying models, so supporting them once gets that whole catalog instead of one more one-off integration — providers/qwen turns out to have been exactly that pattern hand-rolled a second time (its own copy of the OpenAI-compatible translation, just pointed at DashScope's base URL). providers/litellm and providers/openrouter are both thin constructors over the OpenAI provider's existing NewOpenAIProviderWithKind(apiKey, baseURL, "openai-compatible") — no new request/stream-translation code. OpenRouter defaults to its public endpoint when baseURL is empty; LiteLLM has none (self-hosted), so callers must supply one. Context-window detection (tokens.ContextWindow) already keys off the model ID's family rather than the provider prefix, specifically so a model exposed under a custom/proxy provider name still gets the right window — so litellm/openrouter models need zero changes there.
This commit is contained in:
1 parent
0ba1b4dbcc
commit
f624e4c7bd
11 files changed
+143
-431
No files matched your search
+4
-4
@@ -98,7 +98,7 @@ type SystemPromptPart struct {
|
||||
// Zero value (ReasoningOff) means no extended reasoning — safe default
|
||||
// for existing call sites that don't set the field. Each provider maps
|
||||
// this to its native config (Anthropic thinking budget, OpenAI
|
||||
// reasoning_effort, Gemini ThinkingConfig, Qwen enable_thinking).
|
||||
// reasoning_effort, Gemini ThinkingConfig).
|
||||
type ReasoningMode string
|
||||
|
||||
const (
|
||||
@@ -295,10 +295,10 @@ func JoinSystemPromptParts(parts []SystemPromptPart) string {
|
||||
// ProviderOptions holds connection details for creating an LLM provider.
|
||||
// Kept here so consumers can pass a single struct around even though the
|
||||
// concrete provider constructors live in subpackages
|
||||
// (harness/providers/{anthropic,openai,gemini,qwen}). Each subpackage's
|
||||
// New() takes the relevant fields directly.
|
||||
// (harness/providers/{anthropic,openai,gemini,litellm,openrouter}). Each
|
||||
// subpackage's New() takes the relevant fields directly.
|
||||
type ProviderOptions struct {
|
||||
APIKey string
|
||||
BaseURL string
|
||||
Kind string // "anthropic" | "openai" | "openai-compatible" | "local" | "gemini" | "qwen"
|
||||
Kind string // "anthropic" | "openai" | "openai-compatible" | "local" | "gemini"
|
||||
}
|
||||
Reference in new issue
Block a user