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
- html2text
- python-dotenv
- questionary
- ollama
- openai
- groq
- asyncio
- tenacity
- civitai-py

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.8.6.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

civitai_models_manager-0.8.6-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: civitai_models_manager-0.8.6.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for civitai_models_manager-0.8.6.tar.gz
Algorithm Hash digest
SHA256 1d74759ae6c72eedc54e0c10bd6ee67182a50709fff5ce0f739d30450c47616f
MD5 e2a7283cef83aa4eff3ef8932b50822b
BLAKE2b-256 2f7353405bfdf9c26a3c115756b3343839e25e01735bf73dbb6abdf7c305b029

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for civitai_models_manager-0.8.6-py3-none-any.whl
Algorithm Hash digest
SHA256 317ae597dca40c0ec78e5ef63b5517f920851ae45de7b1740d57c626616669c2
MD5 de5e6a7130f498326b716ee3d6c2a0ec
BLAKE2b-256 82c8d0edc20ce11d6412447d7db6c79b1f09050829eeae0acef5082fc93d30a9

See more details on using hashes here.

Supported by

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