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

chore: return model size after pulled #1626

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

louis-menlo
Copy link
Contributor

Describe Your Changes

  • Clients like Jan view the model's size as metadata for local models. This helps users determine compatibility with their computer specs.
  • This PR saves the model's size as metadata (in bytes).

model.yaml
Screenshot 2024-11-04 at 14 54 03

API Response body
Screenshot 2024-11-04 at 14 58 06

API Playground
image

Changes made

The provided git diff introduces changes primarily focused on tracking and handling a new attribute called size within the ModelConfig struct. Here are the key changes summarized:

  1. ModelConfig Struct Update:

    • A new field uint64_t size is added to the ModelConfig struct to store the size of the model.
    • FromJson method is updated to parse the size attribute from JSON if present.
    • ToJson method is updated to include the size attribute in the JSON output.
    • Print method now prints the size attribute along with other attributes.
  2. YamlHandler Update:

    • In UpdateModelConfig, the YAML node is updated to include the size of the model if it is not NaN.
    • Likely missed the context, but casting size of type uint64_t to double for NaN check is unusual since uint64_t can't be NaN.
  3. ParseGguf Function Update:

    • The function signature of ParseGguf is updated to include an optional std::uint64_t size parameter.
    • The size is set on model_config with a default of 0 if no size is provided.
  4. Model Service Update:

    • In two functions (HandleDownloadUrlAsync and HandleUrl), after a download task is finished, the total downloaded size (model_size) is calculated by summing up bytes from all items in finishedTask.items.
    • ParseGguf is called with the computed model_size to ensure the size is recorded in the ModelConfig.

These changes enhance the system to manage and persist the size of model files across configurations and YAML updates.

@louis-menlo louis-menlo requested a review from a team November 4, 2024 08:03
Copy link
Contributor

github-actions bot commented Nov 4, 2024

Preview URL: https://f638fa2b.cortex-docs.pages.dev

@louis-menlo louis-menlo merged commit 5684fe6 into dev Nov 4, 2024
5 checks passed
@louis-menlo louis-menlo deleted the chore/return-model-size branch November 4, 2024 09:44
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.

3 participants