Skip to content

fix: show resolved embedding model display name in dataset list - #17415

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:fix/dataset-list-embedding-model-display
Jul 27, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:fix/dataset-list-embedding-model-display

Conversation

@euvre

@euvre euvre commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The dataset list API (GET /api/v1/datasets) returned the raw knowledgebase.embd_id value. When a dataset's embedding model is stored as a tenant_model reference, this value is a 32-char hex tenant_model ID, so the knowledge base selector in the UI displayed an unreadable ID (e.g. e21f824a8f8749b88d5a4d7d50eabe) instead of the concrete model name.

This PR mirrors the memory list behavior: the tenant_model ID is resolved to its modelName@instance@provider display name (e.g. BAAI/bge-m3@s-1@SILICONFLOW) when building the dataset list response.

Changes:

  • Export ResolveTenantModelDisplayName in internal/service/memory.go so both the memory list and the dataset list share a single resolution path.
  • Add TenantEmbdID to KnowledgebaseListItem and select knowledgebase.tenant_embd_id in GetByTenantIDs.
  • In ListDatasets, resolve embedding_model to the display name with a per-request cache, falling back to the raw value when resolution fails or the value is already a name@provider string; a hex embd_id without tenant_embd_id is also resolved directly.

The dataset list API returned the raw knowledgebase.embd_id value,
which is a 32-char hex tenant_model ID when the dataset was created
with a tenant_model reference. The frontend knowledge base selector
displayed this raw ID instead of a readable model name.

Mirror the memory list behavior: resolve the tenant_model ID to its
modelName@instance@provider display name when building the dataset
list response, reusing the same resolution helper (now exported as
ResolveTenantModelDisplayName) with a per-request cache.
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 27, 2026
@euvre euvre added the ci Continue Integration label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Knowledge-base listings now include tenant embedding IDs. Dataset and memory list responses use the exported model-name resolver to populate human-readable embedding and language model values.

Changes

Tenant model display resolution

Layer / File(s) Summary
Propagate tenant embedding IDs
internal/dao/kb.go, internal/entity/dataset.go
Knowledge-base queries select tenant_embd_id, and KnowledgebaseListItem serializes it as an optional tenant_embd_id field.
Resolve model display names
internal/service/dataset/crud.go, internal/service/memory.go
Dataset listings resolve embedding model names with a per-request cache, while memory listings use the exported ResolveTenantModelDisplayName helper for llm_id and embd_id.

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

Possibly related PRs

Suggested labels: 🐞 bug

Suggested reviewers: xugangqiang

Poem

A bunny found IDs in a data stream,
And polished model names to gleam.
Lists now hop with labels bright,
Cached and clear from morn to night.
Carrot cheers for cleaner sight! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main user-facing change: resolving the embedding model display name in the dataset list.
Description check ✅ Passed The description includes the required Summary section and gives sufficient background and implementation details for reviewers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

@euvre
euvre requested a review from wangq8 July 27, 2026 06:46

@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 `@internal/service/dataset/crud.go`:
- Around line 394-398: Update the embedding ID handling around tenantEmbdID and
ResolveTenantModelDisplayName: trim both TenantEmbdID and EmbdID before checking
emptiness, applying the hexadecimal fallback, and resolving the display name.
Preserve the fallback behavior for empty or whitespace-only tenant IDs while
passing normalized values to the resolver.
🪄 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: 4472e973-50ef-4b1e-9f59-3474beea9d40

📥 Commits

Reviewing files that changed from the base of the PR and between a6a67c5 and 885816b.

📒 Files selected for processing (4)
  • internal/dao/kb.go
  • internal/entity/dataset.go
  • internal/service/dataset/crud.go
  • internal/service/memory.go

Comment on lines +394 to +398
tenantEmbdID := ptrStringValue(kb.TenantEmbdID)
if tenantEmbdID == "" && isHexID(kb.EmbdID) {
tenantEmbdID = kb.EmbdID
}
item["embedding_model"] = service.ResolveTenantModelDisplayName(tenantEmbdID, kb.EmbdID, modelNameCache)

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 | 🟡 Minor | ⚡ Quick win

Normalize embedding IDs before selecting the fallback.

TenantEmbdID is not trimmed before the empty check. A whitespace-only value skips the hexadecimal fallback; the resolver then trims it to empty and returns the raw EmbdID instead of resolving it. Trim both IDs before isHexID and resolution.

Proposed fix
-		tenantEmbdID := ptrStringValue(kb.TenantEmbdID)
-		if tenantEmbdID == "" && isHexID(kb.EmbdID) {
-			tenantEmbdID = kb.EmbdID
+		tenantEmbdID := strings.TrimSpace(ptrStringValue(kb.TenantEmbdID))
+		embdID := strings.TrimSpace(kb.EmbdID)
+		if tenantEmbdID == "" && isHexID(embdID) {
+			tenantEmbdID = embdID
 		}
-		item["embedding_model"] = service.ResolveTenantModelDisplayName(tenantEmbdID, kb.EmbdID, modelNameCache)
+		item["embedding_model"] = service.ResolveTenantModelDisplayName(tenantEmbdID, embdID, modelNameCache)
📝 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
tenantEmbdID := ptrStringValue(kb.TenantEmbdID)
if tenantEmbdID == "" && isHexID(kb.EmbdID) {
tenantEmbdID = kb.EmbdID
}
item["embedding_model"] = service.ResolveTenantModelDisplayName(tenantEmbdID, kb.EmbdID, modelNameCache)
tenantEmbdID := strings.TrimSpace(ptrStringValue(kb.TenantEmbdID))
embdID := strings.TrimSpace(kb.EmbdID)
if tenantEmbdID == "" && isHexID(embdID) {
tenantEmbdID = embdID
}
item["embedding_model"] = service.ResolveTenantModelDisplayName(tenantEmbdID, embdID, modelNameCache)
🤖 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/service/dataset/crud.go` around lines 394 - 398, Update the
embedding ID handling around tenantEmbdID and ResolveTenantModelDisplayName:
trim both TenantEmbdID and EmbdID before checking emptiness, applying the
hexadecimal fallback, and resolving the display name. Preserve the fallback
behavior for empty or whitespace-only tenant IDs while passing normalized values
to the resolver.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. This correctly resolves tenant model IDs to human-readable display names in the dataset list, matching the existing memory list behavior.

What works well:

  • ResolveTenantModelDisplayName is properly exported (uppercase) and shared between both the memory list and dataset list, avoiding code duplication.
  • Per-request modelNameCache avoids redundant DB lookups when multiple datasets share the same embedding model — same pattern already proven in ListMemories.
  • TenantEmbdID is added to both the DAO query and the entity struct — correct schema alignment.
  • Edge cases handled:
    • kb.TenantEmbdID is nil → ptrStringValue returns "", then falls through to hex ID fallback
    • kb.EmbdID is a 32-char hex without a separate tenant_embd_id → direct resolution attempt via isHexID
    • Resolution fails → falls back to raw embd_id value (graceful degradation)
    • Value already in name@provider format → ResolveTenantModelDisplayName returns it as-is (early return on @ check)

No regressions, no new issues introduced. ✅

@wangq8
wangq8 requested a review from Lynn-Inf July 27, 2026 09:32

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants