-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactor(cli): migrate inference-config.js to TypeScript #1265
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
Merged
+181
−238
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
448a863
refactor(cli): extract pure functions from onboard.js to typed TypeSc…
cv 65fa902
test: add co-located tests for extracted TypeScript modules
cv eec919d
fix: make buildControlUiUrls token parameter optional
cv eb16b9e
Merge branch 'main' into cv/extract-onboard-pure-fns
cv 01ced3b
fix(ci): build CLI TypeScript modules before type-checking
cv d3e2c33
Merge branch 'cv/extract-onboard-pure-fns' of github.com:NVIDIA/NemoC…
cv 2ac85ce
refactor(cli): migrate preflight.js to TypeScript (#1262)
cv 4b7aa88
refactor(cli): migrate inference-config.js to TypeScript
cv 733b530
Merge branch 'main' into cv/migrate-inference-config-ts
cv 3e241bc
fix: add build:cli to prepare hook and simplify getOpenClawPrimaryMod…
cv f7050ea
Merge branch 'main' into cv/migrate-inference-config-ts
cv cdfc28e
merge: update branch with main
cv 6dc2ed1
fix: fail loudly on build:cli errors and restore full-object test ass…
cv 8195571
Merge branch 'main' into cv/migrate-inference-config-ts
ericksoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,143 +1,7 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| // Thin re-export shim — the implementation lives in src/lib/inference-config.ts, | ||
| // compiled to dist/lib/inference-config.js. | ||
|
|
||
| const INFERENCE_ROUTE_URL = "https://inference.local/v1"; | ||
| const DEFAULT_CLOUD_MODEL = "nvidia/nemotron-3-super-120b-a12b"; | ||
| const CLOUD_MODEL_OPTIONS = [ | ||
| { id: "nvidia/nemotron-3-super-120b-a12b", label: "Nemotron 3 Super 120B" }, | ||
| { id: "moonshotai/kimi-k2.5", label: "Kimi K2.5" }, | ||
| { id: "z-ai/glm5", label: "GLM-5" }, | ||
| { id: "minimaxai/minimax-m2.5", label: "MiniMax M2.5" }, | ||
| { id: "qwen/qwen3.5-397b-a17b", label: "Qwen3.5 397B A17B" }, | ||
| { id: "openai/gpt-oss-120b", label: "GPT-OSS 120B" }, | ||
| ]; | ||
| const DEFAULT_ROUTE_PROFILE = "inference-local"; | ||
| const DEFAULT_ROUTE_CREDENTIAL_ENV = "OPENAI_API_KEY"; | ||
| const MANAGED_PROVIDER_ID = "inference"; | ||
| const { DEFAULT_OLLAMA_MODEL } = require("./local-inference"); | ||
|
|
||
| function getProviderSelectionConfig(provider, model) { | ||
| switch (provider) { | ||
| case "nvidia-prod": | ||
| case "nvidia-nim": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || DEFAULT_CLOUD_MODEL, | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: DEFAULT_ROUTE_CREDENTIAL_ENV, | ||
| provider, | ||
| providerLabel: "NVIDIA Endpoints", | ||
| }; | ||
| case "openai-api": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || "gpt-5.4", | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: "OPENAI_API_KEY", | ||
| provider, | ||
| providerLabel: "OpenAI", | ||
| }; | ||
| case "anthropic-prod": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || "claude-sonnet-4-6", | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: "ANTHROPIC_API_KEY", | ||
| provider, | ||
| providerLabel: "Anthropic", | ||
| }; | ||
| case "compatible-anthropic-endpoint": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || "custom-anthropic-model", | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: "COMPATIBLE_ANTHROPIC_API_KEY", | ||
| provider, | ||
| providerLabel: "Other Anthropic-compatible endpoint", | ||
| }; | ||
| case "gemini-api": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || "gemini-2.5-flash", | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: "GEMINI_API_KEY", | ||
| provider, | ||
| providerLabel: "Google Gemini", | ||
| }; | ||
| case "compatible-endpoint": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || "custom-model", | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: "COMPATIBLE_API_KEY", | ||
| provider, | ||
| providerLabel: "Other OpenAI-compatible endpoint", | ||
| }; | ||
| case "vllm-local": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || "vllm-local", | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: DEFAULT_ROUTE_CREDENTIAL_ENV, | ||
| provider, | ||
| providerLabel: "Local vLLM", | ||
| }; | ||
| case "ollama-local": | ||
| return { | ||
| endpointType: "custom", | ||
| endpointUrl: INFERENCE_ROUTE_URL, | ||
| ncpPartner: null, | ||
| model: model || DEFAULT_OLLAMA_MODEL, | ||
| profile: DEFAULT_ROUTE_PROFILE, | ||
| credentialEnv: DEFAULT_ROUTE_CREDENTIAL_ENV, | ||
| provider, | ||
| providerLabel: "Local Ollama", | ||
| }; | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function getOpenClawPrimaryModel(provider, model) { | ||
| const resolvedModel = | ||
| model || (provider === "ollama-local" ? DEFAULT_OLLAMA_MODEL : DEFAULT_CLOUD_MODEL); | ||
| return resolvedModel ? `${MANAGED_PROVIDER_ID}/${resolvedModel}` : null; | ||
| } | ||
|
|
||
| function parseGatewayInference(output) { | ||
| if (!output || /Not configured/i.test(output)) return null; | ||
| const provider = output.match(/Provider:\s*(.+)/); | ||
| const model = output.match(/Model:\s*(.+)/); | ||
| if (!provider && !model) return null; | ||
| return { | ||
| provider: provider ? provider[1].trim() : null, | ||
| model: model ? model[1].trim() : null, | ||
| }; | ||
| } | ||
|
|
||
| module.exports = { | ||
| CLOUD_MODEL_OPTIONS, | ||
| DEFAULT_CLOUD_MODEL, | ||
| DEFAULT_OLLAMA_MODEL, | ||
| DEFAULT_ROUTE_CREDENTIAL_ENV, | ||
| DEFAULT_ROUTE_PROFILE, | ||
| INFERENCE_ROUTE_URL, | ||
| MANAGED_PROVIDER_ID, | ||
| getOpenClawPrimaryModel, | ||
| getProviderSelectionConfig, | ||
| parseGatewayInference, | ||
| }; | ||
| module.exports = require("../../dist/lib/inference-config"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.