Skip to content

fix(provider): support editing fetched model types before save - #17728

Merged
JinHai-CN merged 6 commits into
infiniflow:mainfrom
Haruko386:master
Aug 3, 2026
Merged

JinHai-CN merged 6 commits into
infiniflow:mainfrom
Haruko386:master

Conversation

@Haruko386

Copy link
Copy Markdown
Member

Summary

As title

now can edit

@Haruko386
Haruko386 requested a review from dcc123456 August 3, 2026 07:48
@Haruko386 Haruko386 added the 🐞 bug Something isn't working, pull request that fix bug. label Aug 3, 2026
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 3, 2026
@Haruko386
Haruko386 marked this pull request as draft August 3, 2026 07:48
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 43ec794b-5b93-488f-9726-154830acbf80

📥 Commits

Reviewing files that changed from the base of the PR and between 3db87ff and 8b60ea0.

📒 Files selected for processing (1)
  • web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts

📝 Walkthrough

Walkthrough

The PR removes video_generation from model catalog classifications, preserves trimmed model IDs as display names, and updates model editing so unattached models change the local catalog without a backend PATCH.

Changes

Model management

Layer / File(s) Summary
Model type classification
conf/all_models.json
Removes video_generation from affected model entries while preserving remaining capabilities.
Model identity handling
internal/entity/models/base_model.go, internal/handler/providers.go, internal/entity/models/*_test.go
ParseListModel no longer adds an @OwnedBy suffix. Provider tests expect unsuffixed model names.
Local model editing
web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts, web/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx
Catalog overrides merge with fetched models and clear after attachment or persistence. Unattached edits update the local catalog. Draft and persisted models retain their respective update paths.

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
Loading

Possibly related PRs

Suggested labels: 🧰 typescript

Suggested reviewers: dcc123456

Poem

A rabbit trims the model rows,
Keeps each name as the catalog shows.
Local edits stay in place,
Saved models PATCH with grace.
Video tags hop away. 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description uses the required Summary heading but provides only a vague statement and no useful background context. Describe the problem, the affected workflow, and how this change allows fetched model types to be edited before saving.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes enabling edits to fetched model types before saving.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Haruko386
Haruko386 marked this pull request as ready for review August 3, 2026 07:48
@Haruko386 Haruko386 added the ci Continue Integration label Aug 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51af9e2 and e91566d.

⛔ Files ignored due to path filters (1)
  • web/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • conf/all_models.json
  • internal/entity/models/base_model.go
  • internal/entity/models/types.go
  • internal/handler/providers.go
  • web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
  • web/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx

Comment thread internal/entity/models/base_model.go Outdated
Comment on lines +348 to +353
var name string
if model.OwnedBy != "" {
modelName = modelName + "@" + model.OwnedBy
name = modelName + "@" + model.OwnedBy
}
modelResponse.Name = modelName
modelResponse.Name = name
modelResponse.ModelName = modelName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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.

Comment thread internal/handler/providers.go Outdated
for _, m := range liveModels {
remoteModels = append(remoteModels, map[string]interface{}{
"name": m.Name,
"name": m.ModelName,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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/models

Repository: 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/models

Repository: 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 200

Repository: 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.go

Repository: 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.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 3, 2026
@Haruko386 Haruko386 removed the ci Continue Integration label Aug 3, 2026
@Haruko386
Haruko386 marked this pull request as draft August 3, 2026 08:45
@Haruko386
Haruko386 marked this pull request as ready for review August 3, 2026 08:45
@Haruko386 Haruko386 added the ci Continue Integration label Aug 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 299239c and 3db87ff.

📒 Files selected for processing (6)
  • internal/entity/models/funasr_test.go
  • internal/entity/models/gitee_test.go
  • internal/entity/models/google_test.go
  • internal/entity/models/volcengine_test.go
  • web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
  • web/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx

@JinHai-CN
JinHai-CN merged commit 9adcd59 into infiniflow:main Aug 3, 2026
3 checks passed
@Haruko386
Haruko386 deleted the master branch August 4, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants