-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add owned_by to models #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on December 9
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an owned_by field to track model ownership/management across the system. The field is added to database models, service layer structs, API models, and all relevant SQL queries.
Key changes:
- Database migration adds
owned_bycolumn with default value "nearai" for existing models - Repository layer updated to include
owned_byin all SELECT, INSERT, and UPDATE queries - API layer uses actual
owned_byvalue instead of hardcoded "system"
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/services/src/models/ports.rs | Added owned_by field to ModelWithPricing struct |
| crates/services/src/admin/ports.rs | Added owned_by to UpdateModelAdminRequest and ModelPricing structs |
| crates/services/src/admin/mod.rs | Added DEFAULT_MODEL_OWNED_BY constant set to "nearai" |
| crates/database/src/repositories/model.rs | Updated all SQL queries to include owned_by field; added default value logic for new model inserts |
| crates/database/src/repositories/admin_composite.rs | Added owned_by field mapping in admin repository |
| crates/database/src/models.rs | Added owned_by to Model and UpdateModelPricingRequest structs |
| crates/database/src/migrations/sql/V0024__add_owned_by_to_models.sql | Migration to add owned_by column and backfill with "nearai" |
| crates/api/src/routes/completions.rs | Changed from hardcoded "system" to actual model's owned_by value |
| crates/api/src/routes/admin.rs | Added owned_by field passthrough in batch upsert endpoint |
| crates/api/src/models.rs | Added owned_by to UpdateModelApiRequest with proper serde rename |
Comments suppressed due to low confidence (1)
crates/database/src/repositories/model.rs:327
- The
create_modelfunction's INSERT statement is missing theowned_byfield. This will cause the insert to fail sinceowned_byis a NOT NULL column. The INSERT should includeowned_byin both the column list and VALUES, and the RETURNING clause should include it as well. Addowned_byto line 323,&model.owned_byto the parameters array around line 338, andowned_byto the RETURNING clause on line 327.
INSERT INTO models (
model_name, model_display_name, model_description, model_icon,
input_cost_per_token, output_cost_per_token,
context_length, verifiable, is_active
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
RETURNING id, model_name, model_display_name, model_description, model_icon,
input_cost_per_token, output_cost_per_token,
context_length, verifiable, is_active, created_at, updated_at
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/database/src/migrations/sql/V0024__add_owned_by_to_models.sql
Outdated
Show resolved
Hide resolved
|
You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 9. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
Fixes #94
Note
Introduce
owned_byfor models end-to-end, including DB column with default, API exposure, admin upsert support, and tests for defaulting, preservation, and override.owned_bycolumn tomodels(defaultnearai) via migrationV0026__add_owned_by_to_models.sql.INSERT/UPDATElogic to read/writeowned_by, withCOALESCE/defaulting on insert and preserve-on-update behavior.owned_bythroughModel/ModelWithPricing, adminUpdateModelAdminRequest, and repository DTOs.owned_byinModelPricingand service responses.ModelMetadataandUpdateModelApiRequestwithownedBy.owned_byin/v1/model/list,/v1/model/{name}, and OpenAI-compatible/v1/models(no longer hardcodedsystem).PATCH /v1/admin/modelsacceptsownedByand returns it in responses.owned_byis populated, defaults tonearaion create, is preserved when omitted on update, and can be overridden.Written by Cursor Bugbot for commit e733ae2. This will update automatically on new commits. Configure here.