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/model import cmd #1248

Merged
merged 16 commits into from
Sep 20, 2024
Merged

Feat/model import cmd #1248

merged 16 commits into from
Sep 20, 2024

Conversation

nguyenhoangthuan99
Copy link
Contributor

@nguyenhoangthuan99 nguyenhoangthuan99 commented Sep 19, 2024

Related Issues

Fix #1249

Add Model Import Command to CLI

This PR introduces a new import subcommand to the models command in our CLI application. The new functionality allows users to import GGUF (GPT-Generated Unified Format) models from local files into the application.

Features

  • Import GGUF models using a specified model ID and file path
  • Automatically parse GGUF files to extract model configuration
  • Generate and store YAML configuration files for imported models
  • Add imported models to the model list for easy management

Implementation Details

The implementation consists of two main parts:

  1. ModelImportCmd class in model_import_cmd.h and model_import_cmd.cpp
  2. CLI11 command setup in the main application file

ModelImportCmd

This class handles the core logic of importing a model:

  • Parses the GGUF file using GGUFHandler
  • Creates a ModelConfig object with the parsed information
  • Generates a YAML configuration file using YamlHandler
  • Adds the model entry to the model list using ModelListUtils

Error handling is implemented to ensure robust operation, including cleaning up partially created files in case of failures.

CLI Setup

The import subcommand is added to the models command with the following options:

  • --model_id: A required option to specify the unique identifier for the imported model
  • --model_path: A required option to specify the absolute path to the GGUF model file

Usage

To import a model, users can now use the following command:

./cortex models import --model_id <unique_model_id> --model_path /path/to/your/model.gguf

@nguyenhoangthuan99 nguyenhoangthuan99 marked this pull request as ready for review September 19, 2024 02:48
@nguyenhoangthuan99
Copy link
Contributor Author

Need to add API for model import, to allow Jan's user import their models

@dan-menlo
Copy link
Contributor

Need to add API for model import, to allow Jan's user import their models

@nguyenhoangthuan99 Will we be implementing the API as a separate issue?

Copy link
Contributor

@dan-menlo dan-menlo left a comment

Choose a reason for hiding this comment

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

Lgtm - will let @vansangpfiev @namchuai evaluate for code.

  • Import API will be separate PR?

@nguyenhoangthuan99
Copy link
Contributor Author

I added API in this PR because the logic is the same, and it makes us easier to track.

@nguyenhoangthuan99 nguyenhoangthuan99 merged commit d9c5b41 into dev Sep 20, 2024
4 checks passed
@nguyenhoangthuan99 nguyenhoangthuan99 deleted the feat/model-import-cmd branch September 20, 2024 04:09
@dan-menlo
Copy link
Contributor

Closes #1058

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.

Model import command
4 participants