Repository navigation
feat: add Standard Compute provider #136
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
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 Standard Compute (OpenAI-compatible Chat Completions) | ||||||||||
| if (config.standardcompute?.apiKey) { | ||||||||||
| providers.push({ | ||||||||||
| name: "standardcompute", | ||||||||||
| type: "standardcompute", | ||||||||||
| baseUrl: config.standardcompute.endpoint || "https://api.stdcmpt.com/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:
Suggested change
|
||||||||||
| enabled: true, | ||||||||||
| models: [ | ||||||||||
| { id: config.standardcompute.model || "StandardCompute", 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 invokeStandardCompute(body) { | ||||||||||||||||||||||
| if (!config.standardcompute?.apiKey) { | ||||||||||||||||||||||
| throw new Error("Standard Compute API key is not configured."); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const { | ||||||||||||||||||||||
| convertAnthropicToolsToOpenRouter, | ||||||||||||||||||||||
| convertAnthropicMessagesToOpenRouter | ||||||||||||||||||||||
| } = require("./openrouter-utils"); | ||||||||||||||||||||||
|
Comment on lines
+2001
to
+2009
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 endpoint = config.standardcompute.endpoint || "https://api.stdcmpt.com/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.
|
||||||||||||||||||||||
| const headers = { | ||||||||||||||||||||||
| "Authorization": `Bearer ${config.standardcompute.apiKey}`, | ||||||||||||||||||||||
| "Content-Type": "application/json", | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const messages = convertAnthropicMessagesToOpenRouter(body.messages || []); | ||||||||||||||||||||||
| if (body.system) { | ||||||||||||||||||||||
| messages.unshift({ role: "system", content: body.system }); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const standardComputeBody = { | ||||||||||||||||||||||
| model: body._suggestionModeModel || body._tierModel || config.standardcompute.model || "StandardCompute", | ||||||||||||||||||||||
| messages, | ||||||||||||||||||||||
| temperature: body.temperature ?? 0.7, | ||||||||||||||||||||||
| max_tokens: body.max_tokens ?? 16384, | ||||||||||||||||||||||
|
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. |
||||||||||||||||||||||
| top_p: body.top_p ?? 1.0, | ||||||||||||||||||||||
| stream: body.stream ?? false, | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const toolsToSend = Array.isArray(body.tools) ? body.tools : []; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (toolsToSend.length > 0) { | ||||||||||||||||||||||
| standardComputeBody.tools = convertAnthropicToolsToOpenRouter(toolsToSend); | ||||||||||||||||||||||
| standardComputeBody.parallel_tool_calls = false; | ||||||||||||||||||||||
| standardComputeBody.tool_choice = forwardToolChoice(body); | ||||||||||||||||||||||
|
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
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. |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| logger.debug({ | ||||||||||||||||||||||
| endpoint, | ||||||||||||||||||||||
| model: standardComputeBody.model, | ||||||||||||||||||||||
| hasTools: !!standardComputeBody.tools, | ||||||||||||||||||||||
| toolCount: standardComputeBody.tools?.length || 0, | ||||||||||||||||||||||
| temperature: standardComputeBody.temperature, | ||||||||||||||||||||||
| max_tokens: standardComputeBody.max_tokens, | ||||||||||||||||||||||
| }, "=== STANDARDCOMPUTE REQUEST ==="); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Chat completions are billable POSTs, so Standard Compute 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: standardComputeBody, | ||||||||||||||||||||||
| maxRetriesOverride: 0, | ||||||||||||||||||||||
| retryableStatusesOverride: [], | ||||||||||||||||||||||
| }, "Standard Compute"); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!response.ok && response.status === 429) { | ||||||||||||||||||||||
| const err = new Error(`Standard Compute rate-limited: ${String(response.json?.error?.message || '').slice(0, 120)}`); | ||||||||||||||||||||||
| 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, | ||||||||||||||||||||||
| standardcompute: invokeStandardCompute, | ||||||||||||||||||||||
| llamacpp: invokeLlamaCpp, | ||||||||||||||||||||||
| lmstudio: invokeLMStudio, | ||||||||||||||||||||||
| bedrock: invokeBedrock, | ||||||||||||||||||||||
|
|
@@ -4968,6 +5035,7 @@ module.exports = { | |||||||||||||||||||||
| invokeAtmoRouter, | ||||||||||||||||||||||
| invokeRuncrate, | ||||||||||||||||||||||
| invokeOpenScale, | ||||||||||||||||||||||
| invokeStandardCompute, | ||||||||||||||||||||||
| 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", "standardcompute", "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. |
||
|
|
||
| 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 'standardcompute' provider entry includes a hardcoded default endpoint URL ('https://api.stdcmpt.com/v1/chat/completions'). This should ideally be configurable via environment variables or configuration files to support different deployments or testing environments.
Suggestion: