Repository navigation
fix(provider): support editing fetched model types before save - #17728
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR removes ChangesModel management
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ModelsSection
participant useModelEdit
participant LocalCatalog
participant DraftInstance
participant InstanceAPI
ModelsSection->>useModelEdit: pass attachment state and catalog callbacks
useModelEdit->>LocalCatalog: update unattached model override
useModelEdit->>DraftInstance: update attached draft model
useModelEdit->>InstanceAPI: PATCH persisted model
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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: 4
🤖 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/base_model.go`:
- Around line 348-353: Update the name construction in the model response
mapping to initialize name with modelName, then append "@" plus model.OwnedBy
only when an owner is present. Preserve ModelName as the unsuffixed modelName
identifier.
In `@internal/handler/providers.go`:
- Line 182: Ensure the live ListModels path populates
ListModelResponse.ModelName for models from BuiltinModel, AnthropicModel,
BedrockModel, NovitaModel, and NvidiaProvider’s helper. Set ModelName during
response construction or apply the Name-to-ModelName fallback before the handler
writes the name field, preserving existing values when already populated.
In
`@web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts`:
- Around line 857-859: Preserve unsaved edits made in the catalog by tracking
overrides keyed by model name alongside catalog state. Update the fetch logic in
useModelsCatalog.handleListModels to merge or reapply those overrides when
replacing state with ret.data, and clear each override after the corresponding
model is successfully saved or added. Keep fetched values for models without
local edits unchanged.
- Around line 856-863: Update the earlier isDraftInstance/updateDraftModel
branch so it only returns when addedSet.has(targetName) is true; allow
unattached draft models to continue into the setCatalog update in the shown
hook, preserving edits after removal.
🪄 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 Plus
Run ID: e8e78cbf-c0d0-4a3e-9e7d-7d8c5d9c77d8
⛔ Files ignored due to path filters (1)
web/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
conf/all_models.jsoninternal/entity/models/base_model.gointernal/entity/models/types.gointernal/handler/providers.goweb/src/pages/user-setting/setting-model/instance-card/models-section/hooks.tsweb/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx
| var name string | ||
| if model.OwnedBy != "" { | ||
| modelName = modelName + "@" + model.OwnedBy | ||
| name = modelName + "@" + model.OwnedBy | ||
| } | ||
| modelResponse.Name = modelName | ||
| modelResponse.Name = name | ||
| modelResponse.ModelName = modelName |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep ListModelResponse.Name populated for unowned models.
When model.OwnedBy is empty, name remains empty. Normal model-list entries then return a blank Name. Initialize name with modelName, then append the owner suffix when present. Keep ModelName as the unsuffixed identifier.
Proposed fix
- var name string
+ name := modelName
if model.OwnedBy != "" {
name = modelName + "@" + model.OwnedBy
}📝 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.
| var name string | |
| if model.OwnedBy != "" { | |
| modelName = modelName + "@" + model.OwnedBy | |
| name = modelName + "@" + model.OwnedBy | |
| } | |
| modelResponse.Name = modelName | |
| modelResponse.Name = name | |
| modelResponse.ModelName = modelName | |
| name := modelName | |
| if model.OwnedBy != "" { | |
| name = modelName + "@" + model.OwnedBy | |
| } | |
| modelResponse.Name = name | |
| modelResponse.ModelName = modelName |
🤖 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/base_model.go` around lines 348 - 353, Update the name
construction in the model response mapping to initialize name with modelName,
then append "@" plus model.OwnedBy only when an owner is present. Preserve
ModelName as the unsuffixed modelName identifier.
| for _, m := range liveModels { | ||
| remoteModels = append(remoteModels, map[string]interface{}{ | ||
| "name": m.Name, | ||
| "name": m.ModelName, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -P 'func\s+\([^)]*\)\s+ListModels\s*\(' internal/entity/models
rg -n -C 5 'ListModelResponse\s*\{|\.ModelName\s*=' internal/entity/models
rg -n -C 4 '\bParseListModel\s*\(' internal/entity/modelsRepository: infiniflow/ragflow
Length of output: 50374
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "== provider manager ListModels =="
sed -n '440,495p' internal/entity/models/model.go
echo
echo "== ListModelResponse definition =="
rg -n -C 4 'type ListModelResponse struct' internal/entity/models
echo
echo "== direct ListModelResponse literal constructors in entity/models =="
rg -n -C 3 'ListModelResponse\s*{' internal/entity/models
echo
echo "== ModelName field assignments in entity/models =="
rg -n '\bModelName\s*=' internal/entity/models || true
echo
echo "== handlers reading list model response/name Map =="
rg -n -A 6 -B 4 'list models|ListModels\(|"name":\s*m\.ModelName|ListModelResponse\[' internal/handler internal/entity/modelsRepository: infiniflow/ragflow
Length of output: 3051
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "== providers.go relevant sections =="
rg -n -C 6 'ListModels|m\.ModelName|ParseListModel' internal/handler/providers.go
echo
echo "== ProviderManager ListModels continuation =="
sed -n '468,530p' internal/entity/models/model.go
echo
echo "== direct ListModelResponse literal constructors in entity/models =="
rg -n -C 3 'ListModelResponse\s*\{' internal/entity/models
echo
echo "== ModelName field assignments in entity/models =="
rg -n '\bModelName\s*=' internal/entity/models || true
echo
echo "== ListModelResponse fields used in handlers/api =="
rg -n 'ListModelResponse|modelName|ModelName' internal/handler internal/service internal/entity/models | head -n 200Repository: infiniflow/ragflow
Length of output: 37494
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "== ListModels return points with direct ListModelResponse literals or ParseListModel =="
python3 - <<'PY'
from pathlib import Path
import re, glob
for path in sorted(glob.glob("internal/entity/models/*.go")):
text = Path(path).read_text()
if "func (" not in text or "ListModels" not in text or "ListModelResponse" not in text:
continue
lines = text.splitlines()
in_func = False
start = None
brace = 0
for i, line in enumerate(lines, 1):
if re.search(r'func\s+\([^)]*\)\s+ListModels\s*\(', line):
in_func = True
start = i
brace = line.count('{') - line.count('}')
continue
if in_func:
brace += line.count('{') - line.count('}')
if brace <= 0:
body = '\n'.join(lines[start-1:i])
direct_literals = re.findall(r'ListModelResponse\s*\{[^}]*\}', body, re.S)
parse_calls = re.findall(r'\bParseListModel\s*\(', body)
returns = re.findall(r'return\s+.*?;', body)
print(path, f"lines({start}-{i})")
print(" returns:", len(returns))
for r in returns[:20]:
print(" ", r.strip().replace('\n', ' '))
print(" direct_literals:", len(direct_literals))
print(" parse_calls:", len(parse_calls))
print(" direct_literals_sample:", direct_literals[:3])
in_func = False
PY
echo
echo "== builtin, anthropic, nvidia, bedrock direct literals sections =="
sed -n '152,160p' internal/entity/models/builtin.go
echo "---"
sed -n '422,434p' internal/entity/models/anthropic.go
echo "---"
sed -n '706,746p' internal/entity/models/nvidia.go
echo "---"
sed -n '820,831p' internal/entity/models/bedrock.goRepository: infiniflow/ragflow
Length of output: 11215
Set m.ModelName in the live ListModels path.
Handlers emitting live provider models depend on ListModelResponse.ModelName, but several ListModels implementations only initialize Name, including BuiltinModel, AnthropicModel, BedrockModel, NovitaModel, and NvidiaProvider’s helper. Either set ModelName when constructing ListModelResponse, or add a fallback such as if m.Name != "" && m.ModelName == "" { m.ModelName = m.Name } before the handler writes 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 `@internal/handler/providers.go` at line 182, Ensure the live ListModels path
populates ListModelResponse.ModelName for models from BuiltinModel,
AnthropicModel, BedrockModel, NovitaModel, and NvidiaProvider’s helper. Set
ModelName during response construction or apply the Name-to-ModelName fallback
before the handler writes the name field, preserving existing values when
already populated.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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
`@web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts`:
- Around line 149-165: The model-list response path in handleListModels must
merge using the latest catalogOverrides rather than the pre-request snapshot.
Add a ref or equivalent current-state source, keep it synchronized in both
updateCatalogModel and clearCatalogOverride, and have applyCatalogOverrides or
the response merge read that current value when the request completes.
🪄 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 Plus
Run ID: fafc73da-7a32-4bd5-99e2-f002d0eceb60
📒 Files selected for processing (6)
internal/entity/models/funasr_test.gointernal/entity/models/gitee_test.gointernal/entity/models/google_test.gointernal/entity/models/volcengine_test.goweb/src/pages/user-setting/setting-model/instance-card/models-section/hooks.tsweb/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx
Summary
As title
now can edit