Repository navigation
Fix: provider name - #16733
Fix: provider name#16733
Conversation
…lated components - Added copyright notice to the following files: - bedrock-modal/index.tsx - add-custom-model-dialog.tsx - addable-toggle-list.tsx - use-custom-model-fields.tsx - constants.ts - generic-api-key-config.ts - get-provider-config.ts - index.ts - local-llm-configs.ts - provider-config-map.ts - utils.ts - hooks/index.ts - hooks/use-list-models-options.tsx - hooks/use-list-models-picker.ts - hooks/use-provider-fields.tsx - hooks/use-provider-modal-actions.ts - index.tsx - types.ts - verify-button/index.tsx - payload-utils.ts
…odel management - Introduced `useListModelsPicker` hook to manage model selection and state. - Created `useProviderFields` hook for dynamic form field configuration based on provider type. - Implemented `useProviderModalActions` for handling modal actions and form submissions. - Added `ProviderConfig` and related types for better type safety and structure. - Developed `VerifyButton` component for verifying model configurations with user feedback. - Enhanced overall user experience in the provider settings by integrating new hooks and components.
- Implemented `useListModelsOptions` for managing model selection options. - Created `useListModelsPicker` to handle model picking logic and state. - Developed `useProviderFields` for dynamic form field configuration based on provider type. - Added `useProviderModalActions` for handling modal actions related to provider configuration. - Defined types for provider configuration and form fields in `types.ts`. - Introduced hooks to streamline the management of provider models and their associated fields.
…eCard for improved instance detail handling
…nce ModelsSection with form value handling
…with edit capabilities
…flow into feat/v0.27.0-model-provider
…flow into feat/v0.27.0-model-provider
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR standardizes provider display names across JSON configs ( ChangesRank-aware model listing
Provider name standardization
Formatting, migration, and tooling cleanups
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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: 3
🧹 Nitpick comments (3)
tools/scripts/rename_models_providers.py (2)
43-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winHandle missing keys gracefully to avoid cryptic KeyError.
If the script is run after a partial rename or a second time,
file_map[old_name]raises an unhelpfulKeyError. Using.get()with a skip-and-warn makes the script more robust and easier to debug.♻️ Proposed fix
for old_name, new_name in CHANGES.items(): - fn = file_map[old_name] + fn = file_map.get(old_name) + if fn is None: + print(f'Warning: "{old_name}" not found in any conf/models/*.json — skipping') + continue path = os.path.join(MODELS_DIR, fn)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/scripts/rename_models_providers.py` around lines 43 - 44, The lookup in rename_models_providers.py currently assumes every CHANGES entry exists in file_map, so reruns or partial renames can fail with a cryptic KeyError. Update the loop around CHANGES.items() to use file_map.get(old_name) and skip entries that are missing, while emitting a warning that names the missing old_name so the script remains debuggable. Keep the existing rename flow intact for hits and make the guard live near the file_map[old_name] access in the rename_models_providers logic.
33-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer
loggingoverAs per coding guidelines for
**/*.py: "Add logging for new flows." Using theloggingmodule instead of♻️ Proposed fix
+import logging import json, os + +logger = logging.getLogger(__name__)And replace
- print(f'{fn}: "{old_name}" -> "{new_name}"') + logger.info('%s: "%s" -> "%s"', fn, old_name, new_name)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/scripts/rename_models_providers.py` around lines 33 - 52, The new flow in main() uses print for status output, but it should use logging instead to match the Python coding guidelines. Update the rename_models_providers.py script by switching the final print in main() to an appropriate logging call, and make sure the module is set up to use the logging module consistently with the rest of the script.Source: Coding guidelines
api/apps/services/provider_api_service.py (1)
260-262: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse explicit
Optionaltype formodel_infoparameter.Ruff flags
model_info: list[dict] = Noneas RUF013 (implicitOptional). Per PEP 484, a parameter with a default ofNoneshould be typed aslist[dict] | None = None.♻️ Proposed fix
- tenant_id: str, provider_id_or_name: str, instance_id_or_name: str, instance_name: str, api_key: str | dict, base_url: str, region: str, model_info: list[dict] = None, verify: bool = True + tenant_id: str, provider_id_or_name: str, instance_id_or_name: str, instance_name: str, api_key: str | dict, base_url: str, region: str, model_info: list[dict] | None = None, verify: bool = True🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/apps/services/provider_api_service.py` around lines 260 - 262, Use an explicit optional type for update_provider_instance’s model_info parameter. Ruff is flagging the implicit None default in this function signature, so update the annotation on model_info in update_provider_instance to use a union with None while keeping the default None value. Keep the change localized to the update_provider_instance signature so the type matches PEP 484 and RUF013 is resolved.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/entity/models/model_test.go`:
- Around line 185-190: The test has inconsistent provider name casing within
TestSiliconFlowProviderConfigLoadsLatestProModels, where one lookup still uses
"SiliconFlow" while the rest use "SILICONFLOW". Update the remaining
FindProvider/GetModelByName call sites in that test to use the same casing as
the other assertions so the naming is consistent throughout the function.
In `@internal/entity/models/voyage.go`:
- Around line 49-51: The VoyageModel.Name() behavior changed to return "Voyage
AI", so update the affected assertion in voyage_test.go to match the new value.
Locate the check around VoyageModel.Name() and change the expected string from
the old lowercase name to the new returned name so the test stays aligned with
the implementation.
In `@tools/scripts/mysql_migration.py`:
- Around line 1841-1850: The initial execute_sql call in the tenant-id lookup
path is redundant because the cursor is always reassigned before any fetch
happens. Update the logic in the migration routine that handles TENANT_ID_FIELDS
so the SELECT is executed only inside the actual branch that uses it: keep the
query in the tenant-specific path and the non-tenant path, and remove the shared
pre-branch query entirely. This ensures the cursor in the table/field loop is
created only once per case and avoids an unnecessary database roundtrip.
---
Nitpick comments:
In `@api/apps/services/provider_api_service.py`:
- Around line 260-262: Use an explicit optional type for
update_provider_instance’s model_info parameter. Ruff is flagging the implicit
None default in this function signature, so update the annotation on model_info
in update_provider_instance to use a union with None while keeping the default
None value. Keep the change localized to the update_provider_instance signature
so the type matches PEP 484 and RUF013 is resolved.
In `@tools/scripts/rename_models_providers.py`:
- Around line 43-44: The lookup in rename_models_providers.py currently assumes
every CHANGES entry exists in file_map, so reruns or partial renames can fail
with a cryptic KeyError. Update the loop around CHANGES.items() to use
file_map.get(old_name) and skip entries that are missing, while emitting a
warning that names the missing old_name so the script remains debuggable. Keep
the existing rename flow intact for hits and make the guard live near the
file_map[old_name] access in the rename_models_providers logic.
- Around line 33-52: The new flow in main() uses print for status output, but it
should use logging instead to match the Python coding guidelines. Update the
rename_models_providers.py script by switching the final print in main() to an
appropriate logging call, and make sure the module is set up to use the logging
module consistently with the rest of the script.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 34247948-e188-4b25-a206-71c6d2be3a01
📒 Files selected for processing (63)
api/apps/services/models_api_service.pyapi/apps/services/provider_api_service.pyapi/db/services/document_service.pyapi/db/services/memory_service.pyconf/models/aliyun.jsonconf/models/avian.jsonconf/models/baichuan.jsonconf/models/baidu.jsonconf/models/cohere.jsonconf/models/fishaudio.jsonconf/models/gitee.jsonconf/models/google.jsonconf/models/hunyuan.jsonconf/models/jiekouai.jsonconf/models/lmstudio.jsonconf/models/localai.jsonconf/models/modelscope.jsonconf/models/novita.jsonconf/models/nvidia.jsonconf/models/ollama.jsonconf/models/siliconflow.jsonconf/models/vllm.jsonconf/models/voyage.jsonconf/models/xinference.jsonconf/models/xunfei.jsondocs/release_notes.mdinternal/cli/user_parser_test.gointernal/development.mdinternal/entity/models/aliyun.gointernal/entity/models/avian.gointernal/entity/models/avian_test.gointernal/entity/models/baichuan.gointernal/entity/models/baidu.gointernal/entity/models/cohere.gointernal/entity/models/factory.gointernal/entity/models/fishaudio.gointernal/entity/models/gitee.gointernal/entity/models/google.gointernal/entity/models/hunyuan.gointernal/entity/models/lmstudio.gointernal/entity/models/localai.gointernal/entity/models/localai_test.gointernal/entity/models/model_test.gointernal/entity/models/modelscope.gointernal/entity/models/modelscope_test.gointernal/entity/models/novita.gointernal/entity/models/ollama.gointernal/entity/models/siliconflow.gointernal/entity/models/sse_scanner_buffer_test.gointernal/entity/models/vllm.gointernal/entity/models/voyage.gointernal/entity/models/xinference.gointernal/entity/models/xinference_test.gointernal/entity/models/xunfei.gointernal/service/deep_researcher.gointernal/service/model_service.gorag/svr/task_executor_refactor/task_handler.pyragflow_deps/download_go_deps.pytest/unit_test/api/db/services/test_get_queue_length.pytest/unit_test/common/test_llm_request_context.pytools/scripts/mysql_migration.pytools/scripts/rename_models_providers.pyweb/src/components/memories-form-field.tsx
| cohere := pm.FindProvider("Cohere") | ||
| if cohere == nil { | ||
| t.Fatal("CoHere provider not found") | ||
| t.Fatal("Cohere provider not found") | ||
| } | ||
| if cohere.URLSuffix.Embedding != "v2/embed" { | ||
| t.Errorf("CoHere embedding suffix=%q", cohere.URLSuffix.Embedding) | ||
| t.Errorf("Cohere embedding suffix=%q", cohere.URLSuffix.Embedding) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Inconsistent provider name casing within the same test function.
Line 375 still uses "SiliconFlow" while the rest of TestSiliconFlowProviderConfigLoadsLatestProModels was updated to "SILICONFLOW" (lines 333, 346, 353, 364). FindProvider/GetModelByName use strings.EqualFold so this is functionally safe, but the mixed casing is inconsistent within a test that was partially updated in this PR.
💚 Proposed fix for casing consistency
- glm51, err := pm.GetModelByName("SiliconFlow", "Pro/zai-org/GLM-5.1")
+ glm51, err := pm.GetModelByName("SILICONFLOW", "Pro/zai-org/GLM-5.1")Also applies to: 333-335, 346-364
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/entity/models/model_test.go` around lines 185 - 190, The test has
inconsistent provider name casing within
TestSiliconFlowProviderConfigLoadsLatestProModels, where one lookup still uses
"SiliconFlow" while the rest use "SILICONFLOW". Update the remaining
FindProvider/GetModelByName call sites in that test to use the same casing as
the other assertions so the naming is consistent throughout the function.
| func (v *VoyageModel) Name() string { | ||
| return "voyage" | ||
| return "Voyage AI" | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
voyage_test.go was not updated and will fail.
The Name() method now returns "Voyage AI", but voyage_test.go (lines 48-52) still asserts Name() == "voyage". This test is not in the changed files list and will break.
🔧 Proposed fix for voyage_test.go
func TestVoyageName(t *testing.T) {
- if got := newVoyageForTest("http://unused").Name(); got != "voyage" {
- t.Errorf("Name()=%q, want %q", got, "voyage")
+ if got := newVoyageForTest("http://unused").Name(); got != "Voyage AI" {
+ t.Errorf("Name()=%q, want %q", got, "Voyage AI")
}
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/entity/models/voyage.go` around lines 49 - 51, The
VoyageModel.Name() behavior changed to return "Voyage AI", so update the
affected assertion in voyage_test.go to match the new value. Locate the check
around VoyageModel.Name() and change the expected string from the old lowercase
name to the new returned name so the test stays aligned with the implementation.
| cursor = self.db.execute_sql( | ||
| f"SELECT id, `{legacy_col}` FROM `{table_name}` " | ||
| f"WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') " | ||
| f"AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | ||
| f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | ||
| ) | ||
|
|
||
| # Also need tenant_id for model lookup | ||
| # For tenant table, the PK is the tenant_id | ||
| # For knowledgebase, dialog, memory we also need tenant_id | ||
| if table_name == "tenant": | ||
| cursor = self.db.execute_sql( | ||
| f"SELECT id, `{legacy_col}` FROM `{table_name}` " | ||
| f"WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') " | ||
| f"AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | ||
| f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Redundant SQL query at line 1841 is always overwritten.
The SELECT at line 1841–1843 executes against the database, but its cursor is unconditionally replaced at line 1849 (for the tenant table) or line 1874 (for other tables) before any rows are fetched. This wastes a DB roundtrip for every (table, field) pair in TENANT_ID_FIELDS.
Remove the initial query and move the cursor assignment into each branch.
♻️ Proposed fix
# Get rows where tenant_*_id is NULL or empty
- cursor = self.db.execute_sql(
- f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''"
- )
-
# Also need tenant_id for model lookup
# For tenant table, the PK is the tenant_id
# For knowledgebase, dialog, memory we also need tenant_id
if table_name == "tenant":
cursor = self.db.execute_sql(
f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''"
)📝 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.
| cursor = self.db.execute_sql( | |
| f"SELECT id, `{legacy_col}` FROM `{table_name}` " | |
| f"WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') " | |
| f"AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | |
| f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | |
| ) | |
| # Also need tenant_id for model lookup | |
| # For tenant table, the PK is the tenant_id | |
| # For knowledgebase, dialog, memory we also need tenant_id | |
| if table_name == "tenant": | |
| cursor = self.db.execute_sql( | |
| f"SELECT id, `{legacy_col}` FROM `{table_name}` " | |
| f"WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') " | |
| f"AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | |
| f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | |
| # Get rows where tenant_*_id is NULL or empty | |
| # Also need tenant_id for model lookup | |
| # For tenant table, the PK is the tenant_id | |
| # For knowledgebase, dialog, memory we also need tenant_id | |
| if table_name == "tenant": | |
| cursor = self.db.execute_sql( | |
| f"SELECT id, `{legacy_col}` FROM `{table_name}` WHERE (`{tenant_id_col}` IS NULL OR `{tenant_id_col}` = '') AND `{legacy_col}` IS NOT NULL AND `{legacy_col}` != ''" | |
| ) |
🧰 Tools
🪛 Ruff (0.15.20)
[error] 1842-1842: Possible SQL injection vector through string-based query construction
(S608)
[error] 1850-1850: Possible SQL injection vector through string-based query construction
(S608)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tools/scripts/mysql_migration.py` around lines 1841 - 1850, The initial
execute_sql call in the tenant-id lookup path is redundant because the cursor is
always reassigned before any fetch happens. Update the logic in the migration
routine that handles TENANT_ID_FIELDS so the SELECT is executed only inside the
actual branch that uses it: keep the query in the tenant-specific path and the
non-tenant path, and remove the shared pre-branch query entirely. This ensures
the cursor in the table/field loop is created only once per case and avoids an
unnecessary database roundtrip.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16733 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Fix:
Feature: