Skip to main content

CLI tool for managing AI models from the CivitAI platform.

Project description

Civitai Models CLI

[!NOTE] Release 0.7.0 was another big refactor for the project. if you had a version before 0.7.0, it is recommended that you re-clone the repo and install the project with pipx install . or pip install . Since the module sturcture has changesd, so has the naming, you will need to do a pipx uninstall civitai-cli-manager or pip uninstall civitai-cli-manager to remove the old version. You can not run the tool using the new name civitai-models or civitai-models --help to see the new commands.

[!WARNING] This tool is provided "as-is". It has primarily been used/tested on Ubuntu systems; YMMV on Windows/Subsystems but should work fine. I will be adding more features and testing on other platforms in the future as I move towards 1.0.0 release.

Overview

Civitai Models CLI is an unofficial Command Line Interface (CLI) tool I created to streamline the process of retrieving and managing AI models from the Civitai platform. This came about as a solution to quickly working with and manage models out side the main site.

I initially intended for this to be just a module in a larger Comfy CLI toolset, but I found it so useful in its standalone format that I decided to share it with anyone who might feel the same way.

screenshot

Why

I needed a more efficient way to download, organize and manage my AI models from the site and the result is this CLI tool that allows me (and you) to store and manage models in a centralized directory. The tool also allows for a quick model summary via the Ollama(OpenAI), OpenAI or Groq if you choose. It is a great way to get a quick overview of a model's capabilities without having to download it first or read a lengthy description that may not be in your native language.

Key Features

  • Quick Model Listing: This tool will quickly list all available models alongside their types and storage paths.

  • Searchable Models: You can search for specific models via the api using plain text or tags.

  • Categorical Stats: Stats are available for each model type, including the number of models and their sizes.

  • Detailed Insights: It retrieves comprehensive information about specific models using their IDs.

  • Effortless Downloads: You can download selected model variants with ease, avoiding the tedious web interface. Just put any model ID or version ID you want to download in and the tool will handle the rest.

  • Simplified Removals: Easily remove unnecessary models from local storage to keep things tidy.

  • Summarized Descriptions: Get summaries of specific models by using 3 different LLMs for enhanced understanding.

Installation (Recommended)

You have a couple of options for installing/running the tool:

Install pipx, then run the tool with the following command

pipx install .

Alternatively, you can install using pip

pip install .

Run tests with:

[!NOTE] You will need to have the pytest package installed to run the tests. Also, testing is not yet complete, so expect some failures...cause I have a 1 year old so time is limited. I will get to it...eventually. I know python....tests are important.

`pytest` in the root directory of the project.

Configuration

[!IMPORTANT] Before using the tool, It's required to set up a .env file in the parent directory of the script or your home user dir [windows] or $HOME/.config/civitai-cli-manager/.env with the following environment variables:

CIVITAI_TOKEN=#https://developer.civitai.com/docs/getting-started/setup-profile#create-an-api-key
MODELS_DIR= #/location/of/your/models/

OLLAMA_API_BASE= # http://localhost:11434 or http://host.docker.internal:11434
OLLAMA_MODEL=tinydolphin # Tuned to tinydolphin..as best I could
HTML_OUT=False # Some models require HTML conversion, some don't
TEMP=0
TOP_P=0

OPENAI_MODEL=gpt-4o-mini # some frontier models are censored and may not explain the desired model
OPENAI_API_KEY= # sk-proj

GROQ_MODEL=llama-3.1-70b-versatile
GROQ_API_KEY=#//

The application intelligently locates your .env file, accommodating various platforms like Windows and Linux, or defaulting to the current directory.

Usage

[!NOTE] You no longer need to grab the id from the URL. You can now search for models by name or tag and get the ID. You can use the search command to search for models by query and filter by tag to get the model ID.

You can also grab the ID from the Civitai... The model ID is the number in the URL after /models/, like so: https://civitai.com/models/`277058`/epicrealism-xl or https://civitai.com/models/`277058`/epicrealism-xl/versions/`453435`. Each model has a unique ID that can be used to download the model and a version ID that can be used to download a specific version of the model.

Available Commands

Once installed via pipx or pip:

# List all available models
civitai-models list

# Statistically summarize all models
civitai-models stats

# Get detailed information about a specific model [display images or description]
civitai-models details 12345 [--images | --desc]

# Download a specific model variant [select flag will prompt you to select a model]
civitai-models download 54321 [--select]

# Remove models from local storage
civitai-models remove

# Get a summary of a specific model with a options to select a LLM [--service ollama | openai | groq]
civitai-models explain 12345 [--service ollama | openai | groq]

Dependencies

This tool requires Python 3.11 or higher and has the following dependencies:

- typer
- rich
- httpx
- shellingham
- tqdm
- civitai
- python-dotenv
- questionary
- ollama
- openai

These dependencies enhance usability, including user interactions, downloadable progress visuals, and environment variable management.

To-Do List

  • Add search locations for .env
  • Add groqCloud integration
  • Add sanity checks for permissions, folder locations, feedback
  • Add feature to download a update to a model if it already exists
  • Add feature to download a specific version of a model
  • Add feature to have Ollama agents suggest a 5 models based on a prompt

Contact

For any inquiries, feedback, or suggestions, please feel free to open an issue on this repository.

License

This project is licensed under the MIT License.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

civitai_models_manager-0.7.6.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

civitai_models_manager-0.7.6-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file civitai_models_manager-0.7.6.tar.gz.

File metadata

File hashes

Hashes for civitai_models_manager-0.7.6.tar.gz
Algorithm Hash digest
SHA256 f9d00b59646fc01e05ee3b0bb56e7b6d1f86bc147d5f1faaeee34ecab2a95ff5
MD5 7fb3f17caf9888a6632fbf2a9fbf58c6
BLAKE2b-256 f74d5e46c5ea3e0179f3ab3ff8d35d85ad014ab65c65e5f7e2ccee5842784c1c

See more details on using hashes here.

File details

Details for the file civitai_models_manager-0.7.6-py3-none-any.whl.

File metadata

File hashes

Hashes for civitai_models_manager-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a7ce7ead6a49a93cd29b15910f93b1ca092e87ff7991892d603e1c7cf49af226
MD5 aad9346afc63fc8c4193bd30a75aece5
BLAKE2b-256 06223ac62eb9cafa0316ad9b6ed7640b281eeb688c0d31cbcc1fbe92efc321df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page