llama-stack icon indicating copy to clipboard operation
llama-stack copied to clipboard

feat: Add tags field for models with dynamic and user-defined population

Open HabebNawatha opened this issue 11 months ago • 0 comments
trafficstars

  • Implemented a Python function to extract tags from the model identifier field for dynamic population.
  • Enabled users to specify tags manually when registering a model.
  • Tags are now included when retrieving model data, enabling enhanced functionality like filtering and categorization based on tags.

What does this PR do?

This PR enhances the model registration and retrieval process by adding support for tags. It introduces a Python function that automatically extracts tags from the model identifier field, allowing dynamic tag population. Additionally, it gives users the ability to specify tags manually during model registration. As a result, tags are now included in the model data when retrieved. enabling advanced features such as filtering and categorization based on tags.

  • [x] Addresses issue (#542)

Test Plan

  • Verified that tags are dynamically populated when a model identifier is provided.
  • Confirmed that users can manually add tags during model registration.
  • Ensured that tags are correctly included in the model data when retrieved.
  • Tested the functionality by calling various APIs, such as models/list, to ensure the tags are displayed in the output.
  • Verified that registering a model with manually added tags successfully stores and includes the tags in the retrieved data.
  • Expected output:
[
    {
        "identifier": "meta-llama/Llama-3.2-1B-Instruct",
        "provider_resource_id": "llama3.2:1b-instruct-fp16",
        "provider_id": "ollama",
        "type": "model",
        "metadata": {},
        "tags": {
            "llama_version": "3.2",
            "model_type": "Instruct",
            "model_size": "1B"
        },
        "model_type": "llm"
    }
]

Reproduction instructions

  1. Register a model with a specified identifier, ensuring the tags field is populated dynamically.
  2. Retrieve the model data and confirm that the tags are included.
  3. Call the models/list API to confirm that the tags are correctly displayed in the output.
  4. Register a model and manually add tags, then verify that the tags are stored and retrieved correctly.

Sources

Please link relevant resources if necessary. N/A

Before submitting

  • [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Ran pre-commit to handle lint / formatting issues.
  • [x] Read the contributor guideline, Pull Request section?
  • [ ] Updated relevant documentation.
  • [ ] Wrote necessary unit or integration tests.

HabebNawatha avatar Dec 14 '24 20:12 HabebNawatha