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 Standard Compute (OpenAI-compatible Chat Completions) | ||
| if (config.standardcompute?.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
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:
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", | ||||||||||||||||||||||||
|
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:
Suggested change
|
||||||||||||||||||||||||
| 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; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+2058
to
+2062
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:
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| async function invokeStandardCompute(body) { | ||||||||||||||||||||||||
| if (!config.standardcompute?.apiKey) { | ||||||||||||||||||||||||
| throw new Error("Standard Compute API key is not configured."); | ||||||||||||||||||||||||
|
|
@@ -4095,6 +4161,7 @@ const PROVIDER_INVOKERS = { | |||||||||||||||||||||||
| atmorouter: invokeAtmoRouter, | ||||||||||||||||||||||||
| runcrate: invokeRuncrate, | ||||||||||||||||||||||||
| openscale: invokeOpenScale, | ||||||||||||||||||||||||
| uberllm: invokeUberLLM, | ||||||||||||||||||||||||
| standardcompute: invokeStandardCompute, | ||||||||||||||||||||||||
| llamacpp: invokeLlamaCpp, | ||||||||||||||||||||||||
| lmstudio: invokeLMStudio, | ||||||||||||||||||||||||
|
|
@@ -5035,6 +5102,7 @@ module.exports = { | |||||||||||||||||||||||
| invokeAtmoRouter, | ||||||||||||||||||||||||
| invokeRuncrate, | ||||||||||||||||||||||||
| invokeOpenScale, | ||||||||||||||||||||||||
| invokeUberLLM, | ||||||||||||||||||||||||
| invokeStandardCompute, | ||||||||||||||||||||||||
| invokeOrcaRouter, | ||||||||||||||||||||||||
| invokeCursor, | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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: