Skip to content

Fix: right-anchored split in web parseModelValue / parseModelUuid - #16737

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
skbs-eng:fix/frontend-parse-model-at-symbol
Jul 20, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
skbs-eng:fix/frontend-parse-model-at-symbol

Conversation

@skbs-eng

@skbs-eng skbs-eng commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #16468.

PR #16468 fixed the Python (api/db/joint_services/tenant_model_service.py split_model_name) and Go (internal/service/model_service.go parseModelName)
parsers to right-anchor the '@'-split on the composite
"model_name@instance@provider" key, but the matching helper in the front-end
(web/src/utils/llm-util.ts parseModelValue) was missed.

parseModelValue used split('@') (anchored on the first '@'), which silently
mangles composite keys whose model_name itself contains '@' (e.g. LM Studio
embedding IDs like text-embedding-nomic-embed-text-v1.5@q8_0):

text-embedding-nomic-embed-text-v1.5@q8_0@lmstudio@LM-Studio

became

model_name: text-embedding-nomic-embed-text-v1.5
model_instance: q8_0@lmstudio
model_provider: LM-Studio

PATCH /api/v1/models/default then sent those to the server, which returned
HTTP 200 with body {"code": 102, "message": "Instance 'q8_0@lmstudio' not found for provider 'LM-Studio'"}. The UI swallowed the body-level error
code, so the failure was silent: no toast, the Embedding field stayed empty.

This change makes parseModelValue do a right-anchored split that mirrors the
Python split_model_name rsplit('@', 2) exactly:

  • 3-part form: model_name@instance@provider -> same three fields.
  • 2-part form: model_name@provider -> model_instance defaults to "default"
    (matching Python).
  • 4+-part form (embedded '@' in model name): last two fields are anchored
    as instance and provider, everything to the left is the bare model name.

parseModelUuid is updated to the same right-anchored split so the
factoryId portion of model_name@factory_id[#instance] keeps the last '@'
as the separator even when the model name itself contains '@'.

Adds jest cases under web/src/utils/tests/llm-util.test.ts (12 total)
covering the plain 3-part, 2-part, 4-part, multi-'@' name, buildModelValue
round-trip and parseModelUuid variants.

Note for reviewers: the front-end is bundled into the published docker
image, so a release containing this fix will need docker compose build --no-cache ragflow-cpu (or equivalent) for it to be visible to end users.

Refs #16468, #16467

Follow-up to infiniflow#16468.

PR infiniflow#16468 fixed the Python (`api/db/joint_services/tenant_model_service.py
split_model_name`) and Go (`internal/service/model_service.go parseModelName`)
parsers to right-anchor the '@'-split on the composite
"model_name@instance@provider" key, but the matching helper in the front-end
(`web/src/utils/llm-util.ts parseModelValue`) was missed.

parseModelValue used `split('@')` (anchored on the first '@'), which silently
mangles composite keys whose model_name itself contains '@' (e.g. LM Studio
embedding IDs like `text-embedding-nomic-embed-text-v1.5@q8_0`):

  text-embedding-nomic-embed-text-v1.5@q8_0@lmstudio@LM-Studio

became

  model_name:     text-embedding-nomic-embed-text-v1.5
  model_instance: q8_0@lmstudio
  model_provider: LM-Studio

`PATCH /api/v1/models/default` then sent those to the server, which returned
HTTP 200 with body `{"code": 102, "message": "Instance 'q8_0@lmstudio' not
found for provider 'LM-Studio'"}`. The UI swallowed the body-level error
code, so the failure was silent: no toast, the Embedding field stayed empty.

This change makes parseModelValue do a right-anchored split that mirrors the
Python `split_model_name` `rsplit('@', 2)` exactly:

  - 3-part form: model_name@instance@provider -> same three fields.
  - 2-part form: model_name@provider -> model_instance defaults to "default"
    (matching Python).
  - 4+-part form (embedded '@' in model name): last two fields are anchored
    as instance and provider, everything to the left is the bare model name.

`parseModelUuid` is updated to the same right-anchored split so the
factoryId portion of `model_name@factory_id[#instance]` keeps the last '@'
as the separator even when the model name itself contains '@'.

Adds jest cases under `web/src/utils/tests/llm-util.test.ts` (12 total)
covering the plain 3-part, 2-part, 4-part, multi-'@' name, buildModelValue
round-trip and parseModelUuid variants.

Note for reviewers: the front-end is bundled into the published docker
image, so a release containing this fix will need `docker compose build
--no-cache ragflow-cpu` (or equivalent) for it to be visible to end users.

Refs infiniflow#16468, infiniflow#16467
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. 🧰 typescript Pull requests that update Typescript code labels Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 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: 8af160c3-e023-412f-8dd7-641281ed1c17

📥 Commits

Reviewing files that changed from the base of the PR and between 5baf408 and 52c3f49.

📒 Files selected for processing (2)
  • web/src/utils/llm-util.ts
  • web/src/utils/tests/llm-util.test.ts

📝 Walkthrough

Walkthrough

This PR fixes model-string parsing in llm-util.ts so that parseModelValue and parseModelUuid correctly handle model names containing embedded @ characters, using right-anchored splitting instead of naive first/last-indexOf-based splits. Corresponding Jest tests are added.

Changes

Right-anchored model string parsing

Layer / File(s) Summary
parseModelValue right-anchored split
web/src/utils/llm-util.ts, web/src/utils/tests/llm-util.test.ts
parseModelValue now splits on the last one or two @ characters, supporting 3-part and 2-part (modelName@providerName, defaulting instance to "default") forms, returning null for empty/no-@ input; tests cover these cases.
buildModelValue round-trip validation
web/src/utils/tests/llm-util.test.ts
Tests confirm buildModelValue output parses back correctly via parseModelValue, including model names with embedded @.
parseModelUuid right-anchored split
web/src/utils/llm-util.ts, web/src/utils/tests/llm-util.test.ts
parseModelUuid now splits on the last @ in the core portion, returning an empty factoryId when absent instead of relying on unreliable split output; tests validate embedded @, #instance suffix handling, and no-@ cases.

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

Poem

A rabbit hopped through strings with @,
Splitting right, not left astray,
Model names once tangled, torn,
Now parse clean as breaking dawn,
Hop, hop, hooray for tests that stay! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main front-end parsing fix.
Description check ✅ Passed The description includes a clear Summary with background context and the PR's purpose.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@skbs-eng

skbs-eng commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@yuzhichang @Lynn-Inf @wangq8 please review

@yuzhichang
yuzhichang requested a review from Lynn-Inf July 12, 2026 12:18

@Lynn-Inf Lynn-Inf 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.

LGTM

@Lynn-Inf
Lynn-Inf requested a review from dcc123456 July 13, 2026 02:20
@skbs-eng

Copy link
Copy Markdown
Contributor Author

please merge, thank you!

@skbs-eng

Copy link
Copy Markdown
Contributor Author

@yuzhichang @Lynn-Inf @wangq8 please merge

@skbs-eng

Copy link
Copy Markdown
Contributor Author

@dcc123456 please merge

@yuzhichang yuzhichang added the ci Continue Integration label Jul 18, 2026
@yuzhichang
yuzhichang merged commit 962fe9f into infiniflow:main Jul 20, 2026
13 of 15 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 size:M This PR changes 30-99 lines, ignoring generated files. 🧪 test Pull requests that update test cases. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants