Repository navigation
feat[Go]: add modelID for delete_model and update_status - #16025
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds two ID-scoped ChangesTenant Model ID-Based Operations and Resolved Routing
Sequence Diagram(s)sequenceDiagram
actor Client
participant Handler as providers.go Handler
participant ModelProviderService
participant TenantModelDAO
participant Driver
rect rgba(100, 149, 237, 0.5)
Note over Client,TenantModelDAO: UpdateModelStatus (ID-based path)
Client->>Handler: PUT /enable-disable {model_id, status}
Handler->>ModelProviderService: UpdateModelStatus(providerName, instanceName, modelName, userID, modelID, status)
ModelProviderService->>TenantModelDAO: FindByID(modelID)
TenantModelDAO-->>ModelProviderService: TenantModel
ModelProviderService->>TenantModelDAO: UpdateStatusByIDAndScope(modelID, providerID, instanceID, status)
TenantModelDAO-->>ModelProviderService: rowsAffected
ModelProviderService-->>Handler: success/NotFound
Handler-->>Client: 200 OK / 404
end
rect rgba(144, 238, 144, 0.5)
Note over Client,Driver: Chat/Embed/Rerank with resolved naming
Client->>Handler: POST /chat or /embed or /rerank
Handler->>ModelProviderService: ChatToModelWithMessages / EmbedText / RerankDocument
ModelProviderService->>TenantModelDAO: resolve tenant entity
TenantModelDAO-->>ModelProviderService: entity (name, baseURL, region)
ModelProviderService->>ModelProviderService: derive resolvedModelName, resolvedProviderName
ModelProviderService->>Driver: newModelDriverForBaseURL(resolvedProviderName, baseURL, region)
Driver-->>ModelProviderService: driver instance
ModelProviderService->>Driver: Chat/Embed/Rerank(resolvedModelName)
Driver-->>Client: response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 3
🤖 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/handler/providers.go`:
- Around line 706-709: The EnableOrDisableModelRequest struct now accepts
model_id for ID-only updates, but the current route handler still
unconditionally requires the path parameter model_name, preventing clients from
using the ID-only mode. Register an additional PATCH route without the
/*model_name path parameter so that requests can be routed to a handler that
supports true ID-only status updates using only the model_id field from the
request body. This new route should complement the existing route that uses
model_name from the path.
In `@internal/service/model_service.go`:
- Around line 1143-1148: The code checks the `err` variable twice against the
same error from GetModelByProviderIDAndInstanceIDAndModelName. After assigning
modelID from utility.GenerateToken() on line 1146, the subsequent if err != nil
check on line 1147 still references the stale error from the GetModel call, not
from GenerateToken, making the create-on-missing logic unreachable. Either
remove the stale error check if GenerateToken cannot fail, or properly capture
and check the error returned by GenerateToken() with a new variable assignment
using := operator instead of reusing the old err variable.
- Around line 1156-1161: The code accessing modelSchema.ModelTypes[0] in the
model assignment block does not check if the ModelTypes slice is non-empty
before indexing, which will cause a panic if the slice is empty. Add a guard
condition to verify that modelSchema.ModelTypes has at least one element before
accessing index 0, and handle the empty case appropriately (either by returning
an error or using a sensible default value).
🪄 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: 05a09cb3-5bc8-4748-9293-b538c67cf5b4
📒 Files selected for processing (5)
internal/dao/tenant_model.gointernal/handler/providers.gointernal/router/router.gointernal/service/model_service.gointernal/service/model_service_test.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16025 +/- ##
=======================================
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:
|
This README provides installation instructions for RAGFlow CLI on Linux, macOS, and Windows, including usage examples for the installation scripts.
Removed commented-out JSON structure for model configurations.
| } | ||
|
|
||
| if count == 0 { | ||
| return common.CodeNotFound, fmt.Errorf("model %s not found", modelID) |
There was a problem hiding this comment.
Seems like there's no tests for this file. Is it possible to add? At least add tests for the method that's being modified.
What problem does this PR solve?
Type of change