Repository navigation
Go: add dimensions for list models and fix some embed-bug in providers - #15940
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThe PR adds support for plural embedding dimensions across the model system. It introduces a ChangesPlural dimensions support for embeddings and models
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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/entity/models/model.go`:
- Around line 390-395: The provider-scoped list path is missing the new
dimension(s) fields: update the code paths that build provider-instance
responses (specifically ModelProviderService.ListInstanceModels and
ProviderManager.ListModels) to include both model.Dimensions and model.Dimension
(same keys "dimensions" and "dimension" as used in
ProviderManager.ListAllModels). Ensure the builder that constructs modelData for
instance-scoped responses mirrors the logic in the ListAllModels branch so
/providers/:provider/:instance/models returns the same contract whether or not
supported=true.
🪄 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: 7a0a8c00-c537-453d-a8c4-4ca4180ea417
📒 Files selected for processing (10)
internal/entity/models/astraflow.gointernal/entity/models/base_model.gointernal/entity/models/cohere.gointernal/entity/models/mistral.gointernal/entity/models/model.gointernal/entity/models/replicate.gointernal/entity/models/siliconflow.gointernal/entity/models/types.gointernal/entity/models/volcengine.gointernal/service/model_service.go
| if model.Dimensions != nil { | ||
| modelData["dimensions"] = model.Dimensions | ||
| } | ||
| if model.Dimension != nil { | ||
| modelData["dimension"] = *model.Dimension | ||
| } |
There was a problem hiding this comment.
Propagate dimension(s) through the provider-scoped list path too.
This only updates ProviderManager.ListAllModels(). The default instance-model response still flows through ProviderManager.ListModels() from ModelProviderService.ListInstanceModels, and that builder still omits both dimension and dimensions. As a result, /providers/:provider/:instance/models stays out of sync with the new list-model contract unless callers pass supported=true.
Suggested follow-up
func (pm *ProviderManager) ListModels(providerName string) ([]map[string]interface{}, error) {
provider := pm.FindProvider(providerName)
if provider == nil {
return nil, fmt.Errorf("provider '%s' not found", providerName)
}
modelList := []map[string]interface{}{}
for _, model := range provider.Models {
modelData := map[string]interface{}{
"name": model.Name,
"max_tokens": model.MaxTokens,
"model_types": model.ModelTypes,
}
+ if model.Dimension != nil {
+ modelData["dimension"] = model.Dimension
+ }
+ if len(model.Dimensions) > 0 {
+ modelData["dimensions"] = model.Dimensions
+ }
modelList = append(modelList, modelData)
}📝 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.
| if model.Dimensions != nil { | |
| modelData["dimensions"] = model.Dimensions | |
| } | |
| if model.Dimension != nil { | |
| modelData["dimension"] = *model.Dimension | |
| } | |
| if model.Dimensions != nil { | |
| modelData["dimensions"] = model.Dimensions | |
| } | |
| if model.Dimension != nil { | |
| modelData["dimension"] = *model.Dimension | |
| } |
🤖 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/model.go` around lines 390 - 395, The provider-scoped
list path is missing the new dimension(s) fields: update the code paths that
build provider-instance responses (specifically
ModelProviderService.ListInstanceModels and ProviderManager.ListModels) to
include both model.Dimensions and model.Dimension (same keys "dimensions" and
"dimension" as used in ProviderManager.ListAllModels). Ensure the builder that
constructs modelData for instance-scoped responses mirrors the logic in the
ListAllModels branch so /providers/:provider/:instance/models returns the same
contract whether or not supported=true.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15940 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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/model_service.go`:
- Around line 249-267: The code appends two entries per model (first a map with
"max_dimension" and then modelData with "dimension"), causing duplicates; remove
the first append and keep a single consistent map (use the modelData variable)
that includes "name", "max_dimension" (or choose one naming and keep it
consistent), "max_tokens", "model_types", "thinking", and only add "dimensions"
when len(model.Dimensions) > 0; update references to model.Name,
model.MaxDimension, model.Dimensions, model.MaxTokens, model.ModelTypes, and
model.Thinking so the function builds and appends just one entry to result.
🪄 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: 399f475f-e6d0-40c2-b8e9-e32ee77590d8
📒 Files selected for processing (9)
internal/entity/models/astraflow.gointernal/entity/models/base_model.gointernal/entity/models/cohere.gointernal/entity/models/mistral.gointernal/entity/models/model.gointernal/entity/models/replicate.gointernal/entity/models/siliconflow.gointernal/entity/models/volcengine.gointernal/service/model_service.go
🚧 Files skipped from review as they are similar to previous changes (7)
- internal/entity/models/cohere.go
- internal/entity/models/volcengine.go
- internal/entity/models/mistral.go
- internal/entity/models/astraflow.go
- internal/entity/models/siliconflow.go
- internal/entity/models/base_model.go
- internal/entity/models/replicate.go
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
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/model_service.go`:
- Around line 249-267: The code appends two entries per model (first a map with
"max_dimension" and then modelData with "dimension"), causing duplicates; remove
the first append and keep a single consistent map (use the modelData variable)
that includes "name", "max_dimension" (or choose one naming and keep it
consistent), "max_tokens", "model_types", "thinking", and only add "dimensions"
when len(model.Dimensions) > 0; update references to model.Name,
model.MaxDimension, model.Dimensions, model.MaxTokens, model.ModelTypes, and
model.Thinking so the function builds and appends just one entry to result.
🪄 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: 399f475f-e6d0-40c2-b8e9-e32ee77590d8
📒 Files selected for processing (9)
internal/entity/models/astraflow.gointernal/entity/models/base_model.gointernal/entity/models/cohere.gointernal/entity/models/mistral.gointernal/entity/models/model.gointernal/entity/models/replicate.gointernal/entity/models/siliconflow.gointernal/entity/models/volcengine.gointernal/service/model_service.go
🚧 Files skipped from review as they are similar to previous changes (7)
- internal/entity/models/cohere.go
- internal/entity/models/volcengine.go
- internal/entity/models/mistral.go
- internal/entity/models/astraflow.go
- internal/entity/models/siliconflow.go
- internal/entity/models/base_model.go
- internal/entity/models/replicate.go
🛑 Comments failed to post (1)
internal/service/model_service.go (1)
249-267:
⚠️ Potential issue | 🟠 Major | ⚡ Quick winRemove the duplicate append in supported-model response building.
Each iteration appends two entries for the same model, so clients receive duplicated rows with inconsistent key sets (
max_dimensionanddimensionvariants). Keep only one append path.Suggested fix
for _, model := range modelList { - result = append(result, map[string]interface{}{ - "name": model.Name, - "max_dimension": model.MaxDimension, - "dimensions": model.Dimensions, - "max_tokens": model.MaxTokens, - "model_types": model.ModelTypes, - "thinking": model.Thinking, - }) modelData := map[string]interface{}{ "name": model.Name, "dimension": model.MaxDimension, "max_tokens": model.MaxTokens, "model_types": model.ModelTypes, "thinking": model.Thinking, } if len(model.Dimensions) > 0 { modelData["dimensions"] = model.Dimensions } result = append(result, modelData) }📝 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.for _, model := range modelList { modelData := map[string]interface{}{ "name": model.Name, "dimension": model.MaxDimension, "max_tokens": model.MaxTokens, "model_types": model.ModelTypes, "thinking": model.Thinking, } if len(model.Dimensions) > 0 { modelData["dimensions"] = model.Dimensions } result = append(result, modelData) }🤖 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/model_service.go` around lines 249 - 267, The code appends two entries per model (first a map with "max_dimension" and then modelData with "dimension"), causing duplicates; remove the first append and keep a single consistent map (use the modelData variable) that includes "name", "max_dimension" (or choose one naming and keep it consistent), "max_tokens", "model_types", "thinking", and only add "dimensions" when len(model.Dimensions) > 0; update references to model.Name, model.MaxDimension, model.Dimensions, model.MaxTokens, model.ModelTypes, and model.Thinking so the function builds and appends just one entry to result.
What problem does this PR solve?
As title
From RAGFlow CLI
Type of change