Skip to content
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

feat:Add new API endpoints for Lora model upload and deletion in DeepApi #88

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Nov 20, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new endpoint for uploading Lora models.
    • Added functionality to delete specified Lora models.
    • Defined a new schema for Lora model uploads, enhancing request structure.

These updates significantly expand the capabilities of the DeepApi, providing users with more control over Lora models.

Copy link

coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes introduce new API endpoints to the DeepApi OpenAPI specification. Two endpoints are added: /lora-model for uploading Lora models via a POST request, and /lora-model/{lora_model_name} for deleting specific Lora models via a DELETE request. A new schema, LoraModelUploadIn, is defined to structure the request body for the upload endpoint, requiring specific fields. The modifications enhance the API's capabilities regarding Lora model management.

Changes

File Change Summary
src/libs/DeepInfra/openapi.yaml Added new endpoint /lora-model (POST) for uploading Lora models; added new endpoint /lora-model/{lora_model_name} (DELETE) for deleting Lora models; defined new schema LoraModelUploadIn with required properties.

Poem

In the meadow where models play,
New paths have sprouted, hip-hip-hooray!
Upload and delete, oh what a sight,
Lora models dancing, hearts so light!
With schemas to guide us, we hop and cheer,
For changes that bring us joy and good cheer! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot enabled auto-merge November 20, 2024 21:17
@github-actions github-actions bot merged commit 6974d10 into main Nov 20, 2024
3 checks passed
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add new API endpoints for Lora model upload and deletion in DeepApi Nov 20, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
src/libs/DeepInfra/openapi.yaml (2)

795-831: Consider enhancing the endpoint documentation and error responses.

The POST /lora-model endpoint could benefit from the following improvements:

  1. Add a detailed description explaining the purpose and behavior of the Lora model upload.
  2. Include additional standard response codes:
    • 401 for unauthorized access attempts
    • 403 for forbidden access (e.g., rate limiting)
    • 409 for potential naming conflicts

Apply this diff to enhance the endpoint:

  /lora-model:
    post:
      summary: Upload Lora Model
+     description: Upload a new Lora model to be used with a base model. The Lora model must be compatible with the specified base model.
      operationId: upload_lora_model_lora_model_post
      parameters:
        - name: xi-api-key
          in: header
          schema:
            title: Xi-Api-Key
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoraModelUploadIn'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModelOut'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeepError'
+       '401':
+         description: Unauthorized - Invalid or missing API key
+         content:
+           application/json:
+             schema:
+               $ref: '#/components/schemas/DeepError'
+       '403':
+         description: Forbidden - Rate limit exceeded or insufficient permissions
+         content:
+           application/json:
+             schema:
+               $ref: '#/components/schemas/DeepError'
+       '409':
+         description: Conflict - Lora model name already exists
+         content:
+           application/json:
+             schema:
+               $ref: '#/components/schemas/DeepError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'

832-867: Enhance the delete endpoint documentation and error responses.

The DELETE /lora-model/{lora_model_name} endpoint could benefit from the following improvements:

  1. Add a detailed description explaining the deletion behavior and its implications.
  2. Include additional standard response codes:
    • 401 for unauthorized access attempts
    • 404 for non-existent Lora models

Apply this diff to enhance the endpoint:

  '/lora-model/{lora_model_name}':
    delete:
      summary: Delete Lora Model
+     description: Permanently delete a Lora model. This operation cannot be undone. Ensure the model is not being used by any active deployments before deletion.
      operationId: delete_lora_model_lora_model__lora_model_name__delete
      parameters:
        - name: lora_model_name
          in: path
          required: true
          schema:
            title: Lora Model Name
            type: string
+         description: The unique name of the Lora model to delete
        - name: xi-api-key
          in: header
          schema:
            title: Xi-Api-Key
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: { }
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeepError'
+       '401':
+         description: Unauthorized - Invalid or missing API key
+         content:
+           application/json:
+             schema:
+               $ref: '#/components/schemas/DeepError'
+       '404':
+         description: Not Found - Lora model does not exist
+         content:
+           application/json:
+             schema:
+               $ref: '#/components/schemas/DeepError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d1c1a84 and f04ac3c.

⛔ Files ignored due to path filters (9)
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraApi.DeleteLoraModel.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraApi.UploadLoraModel.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraApi.DeleteLoraModel.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraApi.UploadLoraModel.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.DeleteLoraModelLoraModelLoraModelNameDeleteResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.DeleteLoraModelLoraModelLoraModelNameDeleteResponse.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.LoraModelUploadIn.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.LoraModelUploadIn.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/DeepInfra/openapi.yaml (2 hunks)

Comment on lines +3654 to +3669
LoraModelUploadIn:
title: LoraModelUploadIn
required:
- hf_model_name
- lora_model_name
type: object
properties:
hf_model_name:
title: Hf Model Name
type: string
hf_token:
title: Hf Token
type: string
lora_model_name:
title: Lora Model Name
type: string
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance the LoraModelUploadIn schema with descriptions and validations.

The schema definition could benefit from the following improvements:

  1. Add descriptive field documentation
  2. Add pattern validation for model names
  3. Include examples for better understanding

Apply this diff to enhance the schema:

    LoraModelUploadIn:
      title: LoraModelUploadIn
+     description: Schema for uploading a Lora model that can be used with a base model for fine-tuning.
      required:
        - hf_model_name
        - lora_model_name
      type: object
      properties:
        hf_model_name:
          title: Hf Model Name
          type: string
+         description: The Hugging Face model name in the format 'username/model-name'
+         pattern: '^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$'
+         example: 'username/my-lora-model'
        hf_token:
          title: Hf Token
          type: string
+         description: Optional Hugging Face access token for private models
+         format: password
        lora_model_name:
          title: Lora Model Name
          type: string
+         description: A unique name for the Lora model in the format 'name-version'
+         pattern: '^[a-zA-Z0-9][a-zA-Z0-9_-]*$'
+         example: 'my-lora-v1'
📝 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
LoraModelUploadIn:
title: LoraModelUploadIn
required:
- hf_model_name
- lora_model_name
type: object
properties:
hf_model_name:
title: Hf Model Name
type: string
hf_token:
title: Hf Token
type: string
lora_model_name:
title: Lora Model Name
type: string
LoraModelUploadIn:
title: LoraModelUploadIn
description: Schema for uploading a Lora model that can be used with a base model for fine-tuning.
required:
- hf_model_name
- lora_model_name
type: object
properties:
hf_model_name:
title: Hf Model Name
type: string
description: The Hugging Face model name in the format 'username/model-name'
pattern: '^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$'
example: 'username/my-lora-model'
hf_token:
title: Hf Token
type: string
description: Optional Hugging Face access token for private models
format: password
lora_model_name:
title: Lora Model Name
type: string
description: A unique name for the Lora model in the format 'name-version'
pattern: '^[a-zA-Z0-9][a-zA-Z0-9_-]*$'
example: 'my-lora-v1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant