def repo_pull(
    repos,
    accept,
    registry_head,
    model_name,
    model_tag,
    models,
    model_path,
    show_progress,
    media_type="application/vnd.ollama.image.model",
    in_existing_cache_fn=None,
):
    """
    Pull a model from a repository.

    Args:
        repos: Repository base directory
        accept: Accept header for the request
        registry_head: Base URL for the registry API
        model_name: Name of the model
        model_tag: Tag of the model
        models: Models directory
        model_path: Target path for the model
        model: Model identifier string
        show_progress: Whether to show download progress
        media_type: Media type of the layer to pull
        in_existing_cache_fn: Function to check if blob exists in cache

    Returns:
        Path to the pulled model
    """
    os.makedirs(models, exist_ok=True)
    manifest_data = fetch_manifest_data(registry_head, model_tag, accept)
    pull_config_blob(repos, accept, registry_head, manifest_data)

    for layer in manifest_data["layers"]:
        layer_digest = layer["digest"]
        if layer["mediaType"] != media_type:
            continue

        pull_blob(
            repos,
            layer_digest,
            accept,
            registry_head,
            model_name,
            model_tag,
            model_path,
            show_progress,
            in_existing_cache_fn,
        )

    return model_path

    Pull a model from a repository.

    Args:
        repos: Repository base directory
        accept: Accept header for the request
        registry_head: Base URL for the registry API
        model_name: Name of the model
        model_tag: Tag of the model
        models: Models directory
        model_path: Target path for the model
        model: Model identifier string
        show_progress: Whether to show download progress
        media_type: Media type of the layer to pull
        in_existing_cache_fn: Function to check if blob exists in cache

    Returns:
        Path to the pulled model
    
ramalama/ollama_repo_utils.py