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.
ModelListUtils Class Implementation
Fix #1241
Overview
The
ModelListUtils
class provides a robust and thread-safe interface for managing a list of machine learning models. It handles operations such as adding, updating, deleting, and retrieving model information, with a focus on maintaining unique identifiers for each model.Key Features
Main Components
ModelEntry Struct
Represents a single model entry with fields:
model_id
: Unique identifier for the modelauthor_repo_id
: Author or repository identifierbranch_name
: Branch name in the repositorypath_to_model_yaml
: Path to the model's YAML filemodel_alias
: Shortened alias for the modelstatus
: Current status of the model (READY or RUNNING)ModelListUtils Class Methods
LoadModelList()
SaveModelList()
GetModelInfo(identifier)
AddModelEntry(new_entry, use_short_alias)
UpdateModelEntry(identifier, updated_entry)
DeleteModelEntry(identifier)
PrintModelInfo(entry)
GenerateShortenedAlias(model_id, entries)
Alias Generation Logic
The
GenerateShortenedAlias
function creates aliases in the following order:model_id_xxx
)llama3.1-7b-gguf:model_id_xxx
)bartowski:llama3.1-7b-gguf/model_id_xxx
)huggingface.co:bartowski/llama3.1-7b-gguf/model_id_xxx
)It returns the shortest unique alias, appending a numeric suffix if necessary to ensure uniqueness.
Usage Example
This implementation provides a flexible and efficient way to manage machine learning models, with a focus on maintaining unique identifiers and thread-safe operations.