Skip to content

Fix: update LayoutRecognizeFormField to accept ownerTenantId and refactor model handling in LLM requests - #16781

Merged
wangq8 merged 4 commits into
infiniflow:mainfrom
dcc123456:fix/share-embedding-model-error
Jul 10, 2026
Merged

wangq8 merged 4 commits into
infiniflow:mainfrom
dcc123456:fix/share-embedding-model-error

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

Fix: update LayoutRecognizeFormField to accept ownerTenantId and refactor model handling in LLM requests

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. ☯️ refactor Pull request that refactor/refine code 🧰 typescript Pull requests that update Typescript code labels Jul 9, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 9, 2026 09:10
@dcc123456 dcc123456 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 9, 2026
@dcc123456
dcc123456 marked this pull request as draft July 9, 2026 09:11
@coderabbitai

coderabbitai Bot commented Jul 9, 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

Run ID: 58105e1d-b563-4242-9357-77d97be945ec

📥 Commits

Reviewing files that changed from the base of the PR and between f0e92ce and b8fbcd5.

📒 Files selected for processing (1)
  • web/src/pages/dataset/dataset-setting/configuration/naive.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/dataset/dataset-setting/configuration/naive.tsx

📝 Walkthrough

Walkthrough

This PR scopes model-tree fetching by tenant through LayoutRecognizeFormField, propagates tenant IDs from agent and dataset forms, updates default-model contracts to use model_id, and submits selected default models directly by identifier.

Changes

Tenant-scoped model selection

Layer / File(s) Summary
Model contracts and tenant-scoped fetching
web/src/components/layout-recognize-form-field.tsx, web/src/hooks/use-llm-request.tsx, web/src/interfaces/database/llm.ts, web/src/interfaces/request/llm.ts
Model contracts and default-model dictionary handling now use model_id; LayoutRecognizeFormField forwards ownerTenantId to model fetching.
Agent form tenant propagation
web/src/pages/agent/form/{begin-form,parser-form,user-fill-up-form}/...
Agent forms obtain ownerTenantId from useOwnerTenantId and pass it to LayoutRecognizeFormField.
Dataset configuration tenant propagation
web/src/pages/dataset/dataset-setting/configuration/{book,laws,manual,naive,one,paper,presentation}.tsx
Dataset configuration pages derive ownerTenantId from knowledgeBase.tenant_id and pass it to LayoutRecognizeFormField.
Direct default-model updates
web/src/pages/user-setting/setting-model/layout/system-setting.tsx
Default-model changes now submit model_id and model_type directly without parsing the selected value.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ConfigurationForm
  participant LayoutRecognizeFormField
  participant useFetchAllAddedModels

  ConfigurationForm->>LayoutRecognizeFormField: ownerTenantId from tenant context
  LayoutRecognizeFormField->>useFetchAllAddedModels: fetch models with ownerTenantId
  useFetchAllAddedModels-->>LayoutRecognizeFormField: tenant-scoped model tree
Loading

Possibly related PRs

Suggested reviewers: wangq8

Poem

A rabbit hopped through model trees bright,
Carrying tenant IDs just right. 🐇
model_id now leads the way,
Forms scope their choices every day.
Hop, hop, hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main changes: LayoutRecognizeFormField now accepts ownerTenantId and LLM model handling was refactored.
Description check ✅ Passed The PR includes the required Summary section and briefly states the change, though it lacks background context.
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.

@dcc123456
dcc123456 marked this pull request as ready for review July 9, 2026 09:12
@dosubot dosubot Bot removed the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 9, 2026
@dcc123456
dcc123456 marked this pull request as draft July 9, 2026 09:12
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 9, 2026
@dcc123456
dcc123456 marked this pull request as ready for review July 9, 2026 09:12

@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/interfaces/request/llm.ts`:
- Around line 121-122: The default-model request/response shape in the LLM
interfaces is out of sync with the current API contract; keep `model_provider`,
`model_instance`, and `model_name` in the `llm.ts` types used by `PATCH
/models/default` and `GET /models/default`, and do not switch these fields to
`model_id` unless the backend and all callers are updated together. Update the
relevant request/response interfaces around the default-model definitions so
they match the existing backend contract and remain compatible with the code
that reads and writes default model settings.
🪄 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: 125008fd-2fa1-48f2-a4aa-d11c08c6c000

📥 Commits

Reviewing files that changed from the base of the PR and between b29a4a6 and f0e92ce.

📒 Files selected for processing (15)
  • web/src/components/layout-recognize-form-field.tsx
  • web/src/hooks/use-llm-request.tsx
  • web/src/interfaces/database/llm.ts
  • web/src/interfaces/request/llm.ts
  • web/src/pages/agent/form/begin-form/index.tsx
  • web/src/pages/agent/form/parser-form/common-form-fields.tsx
  • web/src/pages/agent/form/user-fill-up-form/index.tsx
  • web/src/pages/dataset/dataset-setting/configuration/book.tsx
  • web/src/pages/dataset/dataset-setting/configuration/laws.tsx
  • web/src/pages/dataset/dataset-setting/configuration/manual.tsx
  • web/src/pages/dataset/dataset-setting/configuration/naive.tsx
  • web/src/pages/dataset/dataset-setting/configuration/one.tsx
  • web/src/pages/dataset/dataset-setting/configuration/paper.tsx
  • web/src/pages/dataset/dataset-setting/configuration/presentation.tsx
  • web/src/pages/user-setting/setting-model/layout/system-setting.tsx

Comment on lines 121 to +122
model_type: string;
model_name: string;
model_id: string;

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:

#!/bin/bash
# Description: Search for backend default-model endpoint handlers to verify they accept model_id.

# Look for backend route handlers or controllers for the defaultModel endpoint
rg -rn 'defaultModel\|default_model\|setDefaultModel' --type py --type js --type ts -g '!node_modules' -g '!web/src' -g '!**/*.test.*' -g '!**/*.spec.*' .

# Also check for any API documentation or OpenAPI specs that define the default model endpoint
fd -i 'openapi\|swagger\|api-doc' --type f | head -20

Repository: infiniflow/ragflow

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the frontend request types and nearby usages.
fd -a 'llm.ts' web/src
rg -n 'model_id|model_provider|model_instance|model_name|setDefaultModel|defaultModel' web/src -g '!**/*.test.*' -g '!**/*.spec.*'

# Search the repository for any backend or API contract definitions tied to default model handling.
rg -n 'defaultModel|default_model|setDefaultModel|ISetDefaultModelRequestBody|IDefaultModel' . -g '!node_modules' -g '!web/node_modules' -g '!**/*.test.*' -g '!**/*.spec.*'

# Show the exact interface block around the changed fields.
python3 - <<'PY'
from pathlib import Path
p = Path('web/src/interfaces/request/llm.ts')
text = p.read_text()
for i, line in enumerate(text.splitlines(), 1):
    if 105 <= i <= 140:
        print(f"{i}: {line}")
PY

Repository: infiniflow/ragflow

Length of output: 49196


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the backend default-model handlers and their returned payload shape.
sed -n '108,230p' api/apps/restful_apis/models_api.py
printf '\n---\n'
sed -n '182,260p' api/apps/services/models_api_service.py
printf '\n---\n'
sed -n '113,140p' web/src/interfaces/database/llm.ts
printf '\n---\n'
sed -n '1,80p' web/src/services/llm-service.ts

Repository: infiniflow/ragflow

Length of output: 8280


Keep the default-model API contract in sync — PATCH /models/default still accepts model_provider, model_instance, and model_name, and GET /models/default still returns those fields. Switching this request/response shape to model_id will break default-model updates and loading unless the backend changes in the same PR.

🤖 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 `@web/src/interfaces/request/llm.ts` around lines 121 - 122, The default-model
request/response shape in the LLM interfaces is out of sync with the current API
contract; keep `model_provider`, `model_instance`, and `model_name` in the
`llm.ts` types used by `PATCH /models/default` and `GET /models/default`, and do
not switch these fields to `model_id` unless the backend and all callers are
updated together. Update the relevant request/response interfaces around the
default-model definitions so they match the existing backend contract and remain
compatible with the code that reads and writes default model settings.

@wangq8
wangq8 merged commit 8236f2c into infiniflow:main Jul 10, 2026
4 checks passed
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 ☯️ refactor Pull request that refactor/refine code size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants