chore: add model import option parameter #1627
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe Your Changes
Users also wanted to import the model using the copy option instead of a symlink. When the original model file was deleted, the model broke in symlink mode.
Changes made
The git diff shows modifications in three files:
cortex.json
,models.cc
, andtest_api_model_import.py
. Here's a brief summary of the changes:cortex.json
(OpenAPI definition file):"option": "symlink"
was added to an example JSON object."option"
was added to the JSON schema, with type"string"
and description"Import options such as symlink or copy."
.models.cc
(Model controller in C++):<filesystem>
header to use file system operations.option
from the request JSON, with a default value of"symlink"
.ImportModel
to handle model file import based on theoption
. Ifoption
is"copy"
, it usesstd::filesystem::copy_file
to copy the GGUF file to the destination. Otherwise, it just adds the current path tomodel_config.files
.test_api_model_import.py
(End-to-end tests for model import):test_model_import_with_name_should_be_success
.option
set to"copy"
.These changes add flexibility to the model import process, allowing for different import methods (copy or symlink). The tests were updated to verify this new functionality.