Repository navigation
feat: add UberLLM provider #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,6 +173,19 @@ async function getConfiguredProviders() { | |
| }); | ||
| } | ||
|
|
||
| // Check UberLLM (OpenAI-compatible Chat Completions) | ||
| if (config.uberllm?.apiKey) { | ||
| providers.push({ | ||
| name: "uberllm", | ||
| type: "uberllm", | ||
| baseUrl: config.uberllm.endpoint || "https://api.uberllm.dev/v1/chat/completions", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion: If URL validation is expected at the provider registration level, consider adding it here for consistency. Otherwise, ensure the invokeUberLLM function properly handles invalid endpoint URLs. |
||
| enabled: true, | ||
| models: [ | ||
| { id: config.uberllm.model || "deepseek/deepseek-v4.1-flash", name: "Configured Model" }, | ||
| ] | ||
| }); | ||
| } | ||
|
|
||
| // Check OpenRouter | ||
| if (config.openrouter?.apiKey) { | ||
| providers.push({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1998,6 +1998,72 @@ async function invokeOpenScale(body) { | |||||||||||
| return response; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| async function invokeUberLLM(body) { | ||||||||||||
| if (!config.uberllm?.apiKey) { | ||||||||||||
| throw new Error("UberLLM API key is not configured."); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const { | ||||||||||||
| convertAnthropicToolsToOpenRouter, | ||||||||||||
| convertAnthropicMessagesToOpenRouter | ||||||||||||
| } = require("./openrouter-utils"); | ||||||||||||
|
|
||||||||||||
| const endpoint = config.uberllm.endpoint || "https://api.uberllm.dev/v1/chat/completions"; | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add explicit validation to ensure the API key is configured, and consider requiring the endpoint and model to be explicitly configured before enabling the provider (similar validation exists in other invoke* functions). Suggestion:
Suggested change
|
||||||||||||
| const headers = { | ||||||||||||
| "Authorization": `Bearer ${config.uberllm.apiKey}`, | ||||||||||||
| "Content-Type": "application/json", | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
| const messages = convertAnthropicMessagesToOpenRouter(body.messages || []); | ||||||||||||
| if (body.system) { | ||||||||||||
| messages.unshift({ role: "system", content: body.system }); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const uberllmBody = { | ||||||||||||
| model: body._suggestionModeModel || body._tierModel || config.uberllm.model || "deepseek/deepseek-v4.1-flash", | ||||||||||||
| messages, | ||||||||||||
| temperature: body.temperature ?? 0.7, | ||||||||||||
| max_tokens: body.max_tokens ?? 16384, | ||||||||||||
| top_p: body.top_p ?? 1.0, | ||||||||||||
| stream: body.stream ?? false, | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
| const toolsToSend = Array.isArray(body.tools) ? body.tools : []; | ||||||||||||
|
|
||||||||||||
| if (toolsToSend.length > 0) { | ||||||||||||
| uberllmBody.tools = convertAnthropicToolsToOpenRouter(toolsToSend); | ||||||||||||
| uberllmBody.parallel_tool_calls = false; | ||||||||||||
| uberllmBody.tool_choice = forwardToolChoice(body); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| logger.debug({ | ||||||||||||
| endpoint, | ||||||||||||
| model: uberllmBody.model, | ||||||||||||
| hasTools: !!uberllmBody.tools, | ||||||||||||
| toolCount: uberllmBody.tools?.length || 0, | ||||||||||||
| temperature: uberllmBody.temperature, | ||||||||||||
| max_tokens: uberllmBody.max_tokens, | ||||||||||||
| }, "=== UBERLLM REQUEST ==="); | ||||||||||||
|
|
||||||||||||
| // Chat completions are billable POSTs, so UberLLM requests are never | ||||||||||||
| // replayed automatically (same policy as invokeAtmoRouter). A 429 is thrown | ||||||||||||
| // so invokeModel's caller can escalate to a different provider/tier. | ||||||||||||
| const response = await performJsonRequest(endpoint, { | ||||||||||||
| headers, | ||||||||||||
| body: uberllmBody, | ||||||||||||
| maxRetriesOverride: 0, | ||||||||||||
| retryableStatusesOverride: [], | ||||||||||||
| }, "UberLLM"); | ||||||||||||
|
|
||||||||||||
| if (!response.ok && response.status === 429) { | ||||||||||||
| const err = new Error(`UberLLM rate-limited: ${String(response.json?.error?.message || '').slice(0, 120)}`); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a fallback that uses the raw response text when JSON parsing fails. Suggestion:
Suggested change
|
||||||||||||
| err.status = 429; | ||||||||||||
| throw err; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return response; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| async function invokeLlamaCpp(body, _incomingHeaders = {}) { | ||||||||||||
| if (!config.llamacpp?.endpoint) { | ||||||||||||
| throw new Error("llama.cpp endpoint is not configured."); | ||||||||||||
|
|
@@ -4029,6 +4095,7 @@ const PROVIDER_INVOKERS = { | |||||||||||
| atmorouter: invokeAtmoRouter, | ||||||||||||
| runcrate: invokeRuncrate, | ||||||||||||
| openscale: invokeOpenScale, | ||||||||||||
| uberllm: invokeUberLLM, | ||||||||||||
| llamacpp: invokeLlamaCpp, | ||||||||||||
| lmstudio: invokeLMStudio, | ||||||||||||
| bedrock: invokeBedrock, | ||||||||||||
|
|
@@ -4968,6 +5035,7 @@ module.exports = { | |||||||||||
| invokeAtmoRouter, | ||||||||||||
| invokeRuncrate, | ||||||||||||
| invokeOpenScale, | ||||||||||||
| invokeUberLLM, | ||||||||||||
| invokeOrcaRouter, | ||||||||||||
| invokeCursor, | ||||||||||||
| PROVIDER_INVOKERS, | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ const NATIVE_THINKING_BEDROCK_MODELS = [ | |
| "claude-haiku", | ||
| ]; | ||
|
|
||
| const REASONING_CONTENT_PROVIDERS = new Set(["moonshot", "openrouter", "edenai", "openai", "azure-openai", "atlas", "cheaperinference", "atmorouter", "runcrate", "openscale", "orcarouter"]); | ||
| const REASONING_CONTENT_PROVIDERS = new Set(["moonshot", "openrouter", "edenai", "openai", "azure-openai", "atlas", "cheaperinference", "atmorouter", "runcrate", "openscale", "uberllm", "orcarouter"]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion: Review other provider registrations (e.g., openrouter, openai) to ensure consistent capability coverage, and add uberllm to any missing capability sets that it supports. |
||
|
|
||
| function supportsNativeThinking(providerType, model) { | ||
| if (NATIVE_THINKING_PROVIDERS.has(providerType)) return true; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API key environment variable name 'UBERLLM_API_KEY' follows an inconsistent naming convention compared to other providers in this file. Most providers use the provider name directly (e.g., 'OPENAI_API_KEY', 'AZURE_OPENAI_API_KEY'). Consider renaming to 'UBERLLM_API_KEY' to match the provider key 'uberllm'.
Suggestion: