Repository navigation
fix: allow arbitrary model names for all providers - #1559
Conversation
📝 WalkthroughWalkthroughWhen no exact default provider/model is found, Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/node/create_nodes/providers.py (1)
99-123:⚠️ Potential issue | 🟠 MajorReturn a cloned instance instead of the cached object to prevent state leaks.
The exact-match path (line 123) returns the cached instance directly, while the fallback creates a new one. Callers mutate the returned object—specifically at
backend/protocol_rpc/endpoints.py:436andbackend/protocol_rpc/validators_init.py:129—which corrupts the shared cache.Extract the cloning logic into a helper function and apply it to both paths:
Suggested fix
+import copy @@ def get_default_provider_for(provider: str, model: str) -> LLMProvider: + def _clone(template: LLMProvider, selected_model: str) -> LLMProvider: + return LLMProvider( + provider=template.provider, + model=selected_model, + config=copy.deepcopy(template.config), + plugin=template.plugin, + plugin_config=copy.deepcopy(template.plugin_config), + ) + llm_providers = get_default_providers() @@ if provider_templates: template = provider_templates[0] - return LLMProvider( - provider=provider, - model=model, - config=template.config.copy() if template.config else {}, - plugin=template.plugin, - plugin_config=( - template.plugin_config.copy() if template.plugin_config else {} - ), - ) + return _clone(template, model) @@ - return matches[0] + return _clone(matches[0], model)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/node/create_nodes/providers.py` around lines 99 - 123, The get_default_provider_for function currently returns a cached LLMProvider instance for exact matches which allows callers (e.g., code paths at backend/protocol_rpc/endpoints.py:436 and backend/protocol_rpc/validators_init.py:129) to mutate shared state; extract the cloning logic used in the fallback into a small helper (e.g., clone_llm_provider(template: LLMProvider) -> LLMProvider) that returns a new LLMProvider with copied config and plugin_config, and use that helper both when returning the fallback template and when returning the single exact match (replace returning matches[0] with returning clone_llm_provider(matches[0])) so callers always receive a fresh instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/node/create_nodes/providers.py`:
- Around line 107-110: The fallback selects provider_templates[0] from
llm_providers which is nondeterministic; make selection deterministic by sorting
the filtered list (provider_templates) by the model name before picking the
first element. Update the logic around provider_templates / template (the
filtered list created from llm_providers where lp.provider == provider) to sort
by the model attribute (e.g., lp.model or the appropriate model field) and then
assign template = provider_templates[0] from the sorted list.
---
Outside diff comments:
In `@backend/node/create_nodes/providers.py`:
- Around line 99-123: The get_default_provider_for function currently returns a
cached LLMProvider instance for exact matches which allows callers (e.g., code
paths at backend/protocol_rpc/endpoints.py:436 and
backend/protocol_rpc/validators_init.py:129) to mutate shared state; extract the
cloning logic used in the fallback into a small helper (e.g.,
clone_llm_provider(template: LLMProvider) -> LLMProvider) that returns a new
LLMProvider with copied config and plugin_config, and use that helper both when
returning the fallback template and when returning the single exact match
(replace returning matches[0] with returning clone_llm_provider(matches[0])) so
callers always receive a fresh instance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 698ad116-b56b-4040-af2f-e1878aeab4c7
📒 Files selected for processing (3)
backend/node/create_nodes/providers.pybackend/node/create_nodes/providers_schema.jsonfrontend/src/assets/schemas/providers_schema.json
💤 Files with no reviewable changes (2)
- backend/node/create_nodes/providers_schema.json
- frontend/src/assets/schemas/providers_schema.json
| # Fallback: use any existing provider config as template for the same provider | ||
| provider_templates = [lp for lp in llm_providers if lp.provider == provider] | ||
| if provider_templates: | ||
| template = provider_templates[0] |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether providers have multiple default templates with divergent config/plugin_config.
python - <<'PY'
import json, pathlib
from collections import defaultdict
base = pathlib.Path("backend/node/create_nodes/default_providers")
rows = defaultdict(list)
for f in sorted(base.glob("*.json")):
data = json.loads(f.read_text())
rows[data["provider"]].append((f.name, data.get("model"), data.get("config"), data.get("plugin_config")))
for provider, items in rows.items():
if len(items) < 2:
continue
signatures = {
(json.dumps(cfg, sort_keys=True), json.dumps(pcfg, sort_keys=True))
for _, _, cfg, pcfg in items
}
if len(signatures) > 1:
print(f"{provider}: {len(items)} templates with differing config/plugin_config")
for name, model, _, _ in items:
print(f" - {name} (model={model})")
PYRepository: genlayerlabs/genlayer-studio
Length of output: 586
🏁 Script executed:
cat -n backend/node/create_nodes/providers.py | head -150 | tail -100Repository: genlayerlabs/genlayer-studio
Length of output: 4479
Make fallback template selection deterministic.
Line 110 picks provider_templates[0], but llm_providers is derived from unsorted defaults. This causes the fallback to select different templates across runs when multiple defaults exist for the same provider. The verification shows 10 OpenAI templates with diverging configurations, confirming this is a real scenario.
Sort the filtered templates by model name to ensure consistent selection:
Suggested fix
- provider_templates = [lp for lp in llm_providers if lp.provider == provider]
+ provider_templates = sorted(
+ (lp for lp in llm_providers if lp.provider == provider),
+ key=lambda lp: lp.model,
+ )
if provider_templates:
template = provider_templates[0]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backend/node/create_nodes/providers.py` around lines 107 - 110, The fallback
selects provider_templates[0] from llm_providers which is nondeterministic; make
selection deterministic by sorting the filtered list (provider_templates) by the
model name before picking the first element. Update the logic around
provider_templates / template (the filtered list created from llm_providers
where lp.provider == provider) to sort by the model attribute (e.g., lp.model or
the appropriate model field) and then assign template = provider_templates[0]
from the sorted list.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/backend_integration_tests_pr.yml:
- Around line 54-60: The current printf lines that append OPENROUTERAPIKEY and
VALIDATORS_CONFIG_JSON interpolate shell variables directly (OPENROUTERAPIKEY,
LLM_PROVIDER, LLM_MODEL) which can corrupt values with shell metacharacters;
change the appending to use safe quoting or a heredoc so variables are written
verbatim (e.g., use a quoted printf format with the variable as a single
argument or use a <<'EOF' heredoc when writing the multi-line
VALIDATORS_CONFIG_JSON) to avoid word-splitting and expansion and ensure the
exact values for OPENROUTERAPIKEY and the VALIDATORS_CONFIG_JSON payload
(including LLM_PROVIDER and LLM_MODEL) are preserved.
In @.github/workflows/load-test-oha.yml:
- Around line 74-81: The printf lines that append OPENROUTERAPIKEY and
VALIDATORS_CONFIG_JSON interpolate shell variables (OPENROUTERAPIKEY,
LLM_PROVIDER, LLM_MODEL) unsafely; replace them with a safe, literal heredoc or
a printf with %s and proper quoting so values are not treated as shell/meta
characters — e.g., use a single-quoted heredoc (or printf '%s\n' with escaped
content) to append OPENROUTERAPIKEY and VALIDATORS_CONFIG_JSON to .env, keeping
the sed removal lines intact and ensuring the variables are expanded exactly
once into the heredoc body.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6873089c-603f-44e1-a66c-567cf519733f
📒 Files selected for processing (2)
.github/workflows/backend_integration_tests_pr.yml.github/workflows/load-test-oha.yml
| # Inject OpenRouter API key | ||
| sed -i "/^OPENROUTERAPIKEY *= *'<add_your_openrouter_api_key_here>'$/d" .env | ||
| printf "\nOPENROUTERAPIKEY='$OPENROUTERAPIKEY'\n" >> .env | ||
|
|
||
| # Override validators config with configured provider/model | ||
| sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env | ||
| printf "\nVALIDATORS_CONFIG_JSON='[\n {\"stake\": 100, \"provider\": \"$LLM_PROVIDER\", \"model\": \"$LLM_MODEL\", \"amount\": 5}\n]'\n" >> .env |
There was a problem hiding this comment.
Shell variable expansion may corrupt values containing special characters.
Directly interpolating $OPENROUTERAPIKEY in printf without proper escaping is unsafe. API keys commonly contain shell metacharacters ($, `, \, !) that will be interpreted by bash, potentially truncating or corrupting the value.
Similarly, $LLM_MODEL values like deepseek/deepseek-v3.2 are safe, but future models with special chars (e.g., @preset/...) could break.
🛡️ Suggested fix using heredoc or proper quoting
- # Inject OpenRouter API key
- sed -i "/^OPENROUTERAPIKEY *= *'<add_your_openrouter_api_key_here>'$/d" .env
- printf "\nOPENROUTERAPIKEY='$OPENROUTERAPIKEY'\n" >> .env
-
- # Override validators config with configured provider/model
- sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env
- printf "\nVALIDATORS_CONFIG_JSON='[\n {\"stake\": 100, \"provider\": \"$LLM_PROVIDER\", \"model\": \"$LLM_MODEL\", \"amount\": 5}\n]'\n" >> .env
+ # Inject OpenRouter API key (use printf %s to avoid interpretation)
+ sed -i "/^OPENROUTERAPIKEY=/d" .env
+ printf '\nOPENROUTERAPIKEY=%s\n' "'${OPENROUTERAPIKEY}'" >> .env
+
+ # Override validators config with configured provider/model
+ sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env
+ cat >> .env <<EOF
+
+VALIDATORS_CONFIG_JSON='[
+ {"stake": 100, "provider": "${LLM_PROVIDER}", "model": "${LLM_MODEL}", "amount": 5}
+]'
+EOF🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/backend_integration_tests_pr.yml around lines 54 - 60, The
current printf lines that append OPENROUTERAPIKEY and VALIDATORS_CONFIG_JSON
interpolate shell variables directly (OPENROUTERAPIKEY, LLM_PROVIDER, LLM_MODEL)
which can corrupt values with shell metacharacters; change the appending to use
safe quoting or a heredoc so variables are written verbatim (e.g., use a quoted
printf format with the variable as a single argument or use a <<'EOF' heredoc
when writing the multi-line VALIDATORS_CONFIG_JSON) to avoid word-splitting and
expansion and ensure the exact values for OPENROUTERAPIKEY and the
VALIDATORS_CONFIG_JSON payload (including LLM_PROVIDER and LLM_MODEL) are
preserved.
| run: | | ||
| # Inject OpenRouter API key | ||
| sed -i "/^OPENROUTERAPIKEY *= *'<add_your_openrouter_api_key_here>'$/d" .env | ||
| printf "\nOPENROUTERAPIKEY='$OPENROUTERAPIKEY'\n" >> .env | ||
|
|
||
| # Override validators config with configured provider/model | ||
| sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env | ||
| printf "\nVALIDATORS_CONFIG_JSON='[\n {\"stake\": 100, \"provider\": \"$LLM_PROVIDER\", \"model\": \"$LLM_MODEL\", \"amount\": 5}\n]'\n" >> .env |
There was a problem hiding this comment.
Same shell expansion concern as in backend_integration_tests_pr.yml.
The printf statements directly interpolate shell variables, which risks corruption if the API key or model names contain shell metacharacters. Consider applying the same heredoc/quoting approach suggested for the other workflow file.
🛡️ Suggested fix
run: |
- # Inject OpenRouter API key
- sed -i "/^OPENROUTERAPIKEY *= *'<add_your_openrouter_api_key_here>'$/d" .env
- printf "\nOPENROUTERAPIKEY='$OPENROUTERAPIKEY'\n" >> .env
-
- # Override validators config with configured provider/model
- sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env
- printf "\nVALIDATORS_CONFIG_JSON='[\n {\"stake\": 100, \"provider\": \"$LLM_PROVIDER\", \"model\": \"$LLM_MODEL\", \"amount\": 5}\n]'\n" >> .env
+ # Inject OpenRouter API key
+ sed -i "/^OPENROUTERAPIKEY=/d" .env
+ printf '\nOPENROUTERAPIKEY=%s\n' "'${OPENROUTERAPIKEY}'" >> .env
+
+ # Override validators config with configured provider/model
+ sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env
+ cat >> .env <<EOF
+
+VALIDATORS_CONFIG_JSON='[
+ {"stake": 100, "provider": "${LLM_PROVIDER}", "model": "${LLM_MODEL}", "amount": 5}
+]'
+EOF📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| run: | | |
| # Inject OpenRouter API key | |
| sed -i "/^OPENROUTERAPIKEY *= *'<add_your_openrouter_api_key_here>'$/d" .env | |
| printf "\nOPENROUTERAPIKEY='$OPENROUTERAPIKEY'\n" >> .env | |
| # Override validators config with configured provider/model | |
| sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env | |
| printf "\nVALIDATORS_CONFIG_JSON='[\n {\"stake\": 100, \"provider\": \"$LLM_PROVIDER\", \"model\": \"$LLM_MODEL\", \"amount\": 5}\n]'\n" >> .env | |
| run: | | |
| # Inject OpenRouter API key | |
| sed -i "/^OPENROUTERAPIKEY=/d" .env | |
| printf '\nOPENROUTERAPIKEY=%s\n' "'${OPENROUTERAPIKEY}'" >> .env | |
| # Override validators config with configured provider/model | |
| sed -i "/^VALIDATORS_CONFIG_JSON=/,/^]'/d" .env | |
| cat >> .env <<EOF | |
| VALIDATORS_CONFIG_JSON='[ | |
| {"stake": 100, "provider": "${LLM_PROVIDER}", "model": "${LLM_MODEL}", "amount": 5} | |
| ]' | |
| EOF |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/load-test-oha.yml around lines 74 - 81, The printf lines
that append OPENROUTERAPIKEY and VALIDATORS_CONFIG_JSON interpolate shell
variables (OPENROUTERAPIKEY, LLM_PROVIDER, LLM_MODEL) unsafely; replace them
with a safe, literal heredoc or a printf with %s and proper quoting so values
are not treated as shell/meta characters — e.g., use a single-quoted heredoc (or
printf '%s\n' with escaped content) to append OPENROUTERAPIKEY and
VALIDATORS_CONFIG_JSON to .env, keeping the sed removal lines intact and
ensuring the variables are expanded exactly once into the heredoc body.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/integration/test_llm_providers_registry.py`:
- Around line 9-16: The current lookup silently defaults unknown provider_name
to "OPENAIKEY"; update the logic around API_KEY_MAP and api_key_env_var to fail
fast: after defining API_KEY_MAP and before using api_key_env_var, check if
provider_name is a key in API_KEY_MAP and if not raise a clear exception (or
call pytest.skip/pytest.fail as appropriate) indicating unsupported
TEST_PROVIDER; use the symbols API_KEY_MAP, provider_name, and api_key_env_var
to locate and replace the defaulting behavior so unknown providers no longer
silently map to OPENAIKEY.
- Around line 25-39: The test finds target_provider_id via next(..., None) which
can be None; before calling post_request_localhost(payload("sim_deleteProvider",
target_provider_id)).json() add a guard: check if target_provider_id is None and
skip the deletion (or assert expected absence) to avoid sending an invalid ID;
update the test around target_provider_id and the post_request_localhost call to
only perform the delete when target_provider_id is not None.
- Around line 6-16: Add explicit type hints for the module-level variables:
annotate provider_name and model_name as str, API_KEY_MAP as Dict[str, str], and
api_key_env_var as str; use the existing symbols provider_name, model_name,
API_KEY_MAP, api_key_env_var to locate the assignments and update them with the
proper typing so the module complies with the project’s type-hinting guidelines.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 102e5b03-ebef-4915-95a3-0443fd908f32
📒 Files selected for processing (1)
tests/integration/test_llm_providers_registry.py
| provider_name = os.environ.get("TEST_PROVIDER", "openai") | ||
| model_name = os.environ.get("TEST_PROVIDER_MODEL", "gpt-4o") | ||
|
|
||
| API_KEY_MAP = { | ||
| "openrouter": "OPENROUTERAPIKEY", | ||
| "openai": "OPENAIKEY", | ||
| "anthropic": "ANTHROPIC_API_KEY", | ||
| "google": "GEMINI_API_KEY", | ||
| } | ||
| api_key_env_var = API_KEY_MAP.get(provider_name, "OPENAIKEY") | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
python - <<'PY'
import ast
from pathlib import Path
path = next(Path(".").rglob("test_llm_providers_registry.py"))
tree = ast.parse(path.read_text())
for node in tree.body:
if isinstance(node, ast.Assign):
targets = [t.id for t in node.targets if isinstance(t, ast.Name)]
if targets:
print(f"Line {node.lineno}: untyped assignment -> {', '.join(targets)}")
PYRepository: genlayerlabs/genlayer-studio
Length of output: 245
🏁 Script executed:
sed -n '6,16p' tests/integration/test_llm_providers_registry.pyRepository: genlayerlabs/genlayer-studio
Length of output: 407
Add type hints for module-level variables to comply with coding guidelines.
Lines 6, 7, 9, and 15 are untyped assignments. Type hints are required for all Python code per project guidelines.
Suggested refactor
-provider_name = os.environ.get("TEST_PROVIDER", "openai")
-model_name = os.environ.get("TEST_PROVIDER_MODEL", "gpt-4o")
+provider_name: str = os.environ.get("TEST_PROVIDER", "openai")
+model_name: str = os.environ.get("TEST_PROVIDER_MODEL", "gpt-4o")
-API_KEY_MAP = {
+API_KEY_MAP: dict[str, str] = {
"openrouter": "OPENROUTERAPIKEY",
"openai": "OPENAIKEY",
"anthropic": "ANTHROPIC_API_KEY",
"google": "GEMINI_API_KEY",
}
-api_key_env_var = API_KEY_MAP.get(provider_name, "OPENAIKEY")
+api_key_env_var: str = API_KEY_MAP.get(provider_name, "OPENAIKEY")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| provider_name = os.environ.get("TEST_PROVIDER", "openai") | |
| model_name = os.environ.get("TEST_PROVIDER_MODEL", "gpt-4o") | |
| API_KEY_MAP = { | |
| "openrouter": "OPENROUTERAPIKEY", | |
| "openai": "OPENAIKEY", | |
| "anthropic": "ANTHROPIC_API_KEY", | |
| "google": "GEMINI_API_KEY", | |
| } | |
| api_key_env_var = API_KEY_MAP.get(provider_name, "OPENAIKEY") | |
| provider_name: str = os.environ.get("TEST_PROVIDER", "openai") | |
| model_name: str = os.environ.get("TEST_PROVIDER_MODEL", "gpt-4o") | |
| API_KEY_MAP: dict[str, str] = { | |
| "openrouter": "OPENROUTERAPIKEY", | |
| "openai": "OPENAIKEY", | |
| "anthropic": "ANTHROPIC_API_KEY", | |
| "google": "GEMINI_API_KEY", | |
| } | |
| api_key_env_var: str = API_KEY_MAP.get(provider_name, "OPENAIKEY") |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/integration/test_llm_providers_registry.py` around lines 6 - 16, Add
explicit type hints for the module-level variables: annotate provider_name and
model_name as str, API_KEY_MAP as Dict[str, str], and api_key_env_var as str;
use the existing symbols provider_name, model_name, API_KEY_MAP, api_key_env_var
to locate the assignments and update them with the proper typing so the module
complies with the project’s type-hinting guidelines.
| API_KEY_MAP = { | ||
| "openrouter": "OPENROUTERAPIKEY", | ||
| "openai": "OPENAIKEY", | ||
| "anthropic": "ANTHROPIC_API_KEY", | ||
| "google": "GEMINI_API_KEY", | ||
| } | ||
| api_key_env_var = API_KEY_MAP.get(provider_name, "OPENAIKEY") | ||
|
|
There was a problem hiding this comment.
Fail fast for unsupported TEST_PROVIDER values.
Line 15 silently defaults unknown providers to "OPENAIKEY", which can hide bad CI/local configuration and produce misleading failures.
Proposed fix
API_KEY_MAP = {
"openrouter": "OPENROUTERAPIKEY",
"openai": "OPENAIKEY",
"anthropic": "ANTHROPIC_API_KEY",
"google": "GEMINI_API_KEY",
}
-api_key_env_var = API_KEY_MAP.get(provider_name, "OPENAIKEY")
+api_key_env_var = API_KEY_MAP.get(provider_name)
+if api_key_env_var is None:
+ raise ValueError(f"Unsupported TEST_PROVIDER: {provider_name}")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| API_KEY_MAP = { | |
| "openrouter": "OPENROUTERAPIKEY", | |
| "openai": "OPENAIKEY", | |
| "anthropic": "ANTHROPIC_API_KEY", | |
| "google": "GEMINI_API_KEY", | |
| } | |
| api_key_env_var = API_KEY_MAP.get(provider_name, "OPENAIKEY") | |
| API_KEY_MAP = { | |
| "openrouter": "OPENROUTERAPIKEY", | |
| "openai": "OPENAIKEY", | |
| "anthropic": "ANTHROPIC_API_KEY", | |
| "google": "GEMINI_API_KEY", | |
| } | |
| api_key_env_var = API_KEY_MAP.get(provider_name) | |
| if api_key_env_var is None: | |
| raise ValueError(f"Unsupported TEST_PROVIDER: {provider_name}") | |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/integration/test_llm_providers_registry.py` around lines 9 - 16, The
current lookup silently defaults unknown provider_name to "OPENAIKEY"; update
the logic around API_KEY_MAP and api_key_env_var to fail fast: after defining
API_KEY_MAP and before using api_key_env_var, check if provider_name is a key in
API_KEY_MAP and if not raise a clear exception (or call pytest.skip/pytest.fail
as appropriate) indicating unsupported TEST_PROVIDER; use the symbols
API_KEY_MAP, provider_name, and api_key_env_var to locate and replace the
defaulting behavior so unknown providers no longer silently map to OPENAIKEY.
| target_provider_id = next( | ||
| ( | ||
| provider["id"] | ||
| for provider in providers_and_models | ||
| if provider["model"] == "gpt-4o" | ||
| and provider["provider"] == "openai" | ||
| if provider["model"] == model_name | ||
| and provider["provider"] == provider_name | ||
| and provider["plugin"] == "openai-compatible" | ||
| ), | ||
| None, | ||
| ) | ||
|
|
||
| # Delete it | ||
| response = post_request_localhost( | ||
| payload("sim_deleteProvider", gpt4o_provider_id) | ||
| payload("sim_deleteProvider", target_provider_id) | ||
| ).json() |
There was a problem hiding this comment.
Guard delete when no existing provider is found.
next(..., None) can return None, and Line 38 then attempts deletion with an invalid ID. This breaks the flow for first-time provider/model combinations.
Proposed fix
target_provider_id = next(
(
provider["id"]
for provider in providers_and_models
if provider["model"] == model_name
and provider["provider"] == provider_name
and provider["plugin"] == "openai-compatible"
),
None,
)
# Delete it
- response = post_request_localhost(
- payload("sim_deleteProvider", target_provider_id)
- ).json()
- assert has_success_status(response)
+ if target_provider_id is not None:
+ response = post_request_localhost(
+ payload("sim_deleteProvider", target_provider_id)
+ ).json()
+ assert has_success_status(response)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/integration/test_llm_providers_registry.py` around lines 25 - 39, The
test finds target_provider_id via next(..., None) which can be None; before
calling post_request_localhost(payload("sim_deleteProvider",
target_provider_id)).json() add a guard: check if target_provider_id is None and
skip the deletion (or assert expected absence) to avoid sending an invalid ID;
update the test around target_provider_id and the post_request_localhost call to
only perform the delete when target_provider_id is not None.
|
🎉 This PR is included in version 0.112.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
providers_schema.json(both backend and frontend copies). Plugin constraints (const) are preserved — they correctly enforce the right plugin per provider.get_default_provider_for(): when no exact (provider, model) match exists indefault_providers/, it clones the plugin/config from any existing default for that provider and substitutes the requested model.Why
Hardcoded model enums prevent adding new models (e.g.
nvidia/nemotron-3-super-120b-a12b:freeon openrouter) without a Studio release. Providers regularly add and deprecate models — the schema shouldn't gate which model strings are valid. The fallback template approach lets any model that works with the provider's API be registered immediately.Files changed
backend/node/create_nodes/providers_schema.json— removed model enums from all providerthenblocksfrontend/src/assets/schemas/providers_schema.json— same (kept in sync)backend/node/create_nodes/providers.py— added fallback provider template inget_default_provider_for()Test plan
Summary by CodeRabbit
Refactor
Bug Fixes
Chores
Tests