All Toolsโ€บLLM Model Switcher
๐Ÿ’ฌ Open-Source LLM FrameworksMay 30, 2026โœ… Tests passing

LLM Model Switcher

A CLI tool to easily switch between different versions of open-source LLM models and frameworks (like Llama.cpp) installed locally. It handles symbolic links, environment variables, and dependencies, enabling developers to test multiple configurations quickly.

What It Does

  • Switch between different versions of locally installed LLM models.
  • Automatically updates symbolic links to point to the active model version.
  • Sets environment variables for the active model.
  • Handles errors gracefully, including missing versions and symbolic link creation issues.

Installation

1. Clone the repository:

git clone <repository_url>
    cd llm_model_switcher

2. Run the tool directly using Python:

python llm_model_switcher.py --activate <model_version> --base-path <path_to_models>

Usage

Command-line Arguments

  • --activate: The model/framework version to activate.
  • --base-path: The base directory where model versions are stored.

Example

python llm_model_switcher.py --activate llama_cpp_v0.2 --base-path /path/to/models

This command will activate the llama_cpp_v0.2 model version and update the symbolic link and environment variable accordingly.

Source Code

import os
import shutil
import argparse

def activate_model(version, base_path):
    """
    Activates the specified model version by updating a symbolic link and setting environment variables.

    Args:
        version (str): The version of the model/framework to activate.
        base_path (str): The base directory where model versions are stored.

    Raises:
        FileNotFoundError: If the specified version does not exist.
        Exception: If the symbolic link cannot be created.
    """
    model_path = os.path.join(base_path, version)
    symlink_path = os.path.join(base_path, "current")

    if not os.path.exists(model_path):
        raise FileNotFoundError(f"Model version '{version}' does not exist in {base_path}.")

    # Update symbolic link
    try:
        if os.path.islink(symlink_path) or os.path.exists(symlink_path):
            os.unlink(symlink_path)
        os.symlink(model_path, symlink_path)
    except OSError as e:
        raise Exception(f"Failed to create symbolic link: {e}")

    # Update environment variable
    os.environ['LLM_MODEL_PATH'] = symlink_path
    print(f"Activated model version: {version}")
    print(f"Environment variable LLM_MODEL_PATH set to: {symlink_path}")

def parse_arguments():
    """
    Parse command-line arguments.

    Returns:
        argparse.Namespace: Parsed arguments.
    """
    parser = argparse.ArgumentParser(
        description="LLM Model Switcher: Switch between different versions of LLM models/frameworks."
    )
    parser.add_argument(
        "--activate",
        type=str,
        required=True,
        help="The model/framework version to activate."
    )
    parser.add_argument(
        "--base-path",
        type=str,
        required=True,
        help="The base directory where model versions are stored."
    )
    return parser.parse_args()

if __name__ == "__main__":
    args = parse_arguments()
    try:
        activate_model(args.activate, args.base_path)
    except FileNotFoundError as e:
        print(f"Error: {e}")
    except Exception as e:
        print(f"Error: {e}")

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
llm_model_switcher
Category
Open-Source LLM Frameworks
Generated
May 30, 2026
Tests
Passing โœ…
Fix Loops
2

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-05-30/llm_model_switcher
cd generated_tools/2026-05-30/llm_model_switcher
pip install -r requirements.txt 2>/dev/null || true
python llm_model_switcher.py
LLM Model Switcher โ€” AI Tools by AutoAIForge