Repository navigation
fix: show resolved embedding model display name in dataset list - #17415
Conversation
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.
📝 WalkthroughWalkthroughKnowledge-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. ChangesTenant model display resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 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
📒 Files selected for processing (4)
internal/dao/kb.gointernal/entity/dataset.gointernal/service/dataset/crud.gointernal/service/memory.go
| tenantEmbdID := ptrStringValue(kb.TenantEmbdID) | ||
| if tenantEmbdID == "" && isHexID(kb.EmbdID) { | ||
| tenantEmbdID = kb.EmbdID | ||
| } | ||
| item["embedding_model"] = service.ResolveTenantModelDisplayName(tenantEmbdID, kb.EmbdID, modelNameCache) |
There was a problem hiding this comment.
🎯 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.
| 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
left a comment
There was a problem hiding this comment.
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:
ResolveTenantModelDisplayNameis properly exported (uppercase) and shared between both the memory list and dataset list, avoiding code duplication.- Per-request
modelNameCacheavoids redundant DB lookups when multiple datasets share the same embedding model — same pattern already proven inListMemories. TenantEmbdIDis added to both the DAO query and the entity struct — correct schema alignment.- Edge cases handled:
kb.TenantEmbdIDis nil →ptrStringValuereturns"", then falls through to hex ID fallbackkb.EmbdIDis a 32-char hex without a separatetenant_embd_id→ direct resolution attempt viaisHexID- Resolution fails → falls back to raw
embd_idvalue (graceful degradation) - Value already in
name@providerformat →ResolveTenantModelDisplayNamereturns it as-is (early return on@check)
No regressions, no new issues introduced. ✅
Summary
The dataset list API (
GET /api/v1/datasets) returned the rawknowledgebase.embd_idvalue. 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@providerdisplay name (e.g.BAAI/bge-m3@s-1@SILICONFLOW) when building the dataset list response.Changes:
ResolveTenantModelDisplayNameininternal/service/memory.goso both the memory list and the dataset list share a single resolution path.TenantEmbdIDtoKnowledgebaseListItemand selectknowledgebase.tenant_embd_idinGetByTenantIDs.ListDatasets, resolveembedding_modelto the display name with a per-request cache, falling back to the raw value when resolution fails or the value is already aname@providerstring; a hexembd_idwithouttenant_embd_idis also resolved directly.