gpt-cli
Command-line interface for ChatGPT, Claude and Bard
Stars: 580
gpt-cli is a command-line interface tool for interacting with various chat language models like ChatGPT, Claude, and others. It supports model customization, usage tracking, keyboard shortcuts, multi-line input, markdown support, predefined messages, and multiple assistants. Users can easily switch between different assistants, define custom assistants, and configure model parameters and API keys in a YAML file for easy customization and management.
README:
Command-line interface for chat LLMs.
- OpenAI
- Anthropic
- Google Gemini
- Cohere
- Other APIs compatible with OpenAI (e.g. Together, OpenRouter, local models with LM Studio)
- Command-Line Interface: Interact with ChatGPT or Claude directly from your terminal.
- Model Customization: Override the default model, temperature, and top_p values for each assistant, giving you fine-grained control over the AI's behavior.
- Usage tracking: Track your API usage with token count and price information.
- Keyboard Shortcuts: Use Ctrl-C, Ctrl-D, and Ctrl-R shortcuts for easier conversation management and input control.
- Multi-Line Input: Enter multi-line mode for more complex queries or conversations.
- Markdown Support: Enable or disable markdown formatting for chat sessions to tailor the output to your preferences.
- Predefined Messages: Set up predefined messages for your custom assistants to establish context or role-play scenarios.
- Multiple Assistants: Easily switch between different assistants, including general, dev, and custom assistants defined in the config file.
- Flexible Configuration: Define your assistants, model parameters, and API key in a YAML configuration file, allowing for easy customization and management.
This install assumes a Linux/OSX machine with Python and pip available.
pip install gpt-command-line
Install latest version from source:
pip install git+https://github.com/kharvd/gpt-cli.git
Or install by cloning the repository manually:
git clone https://github.com/kharvd/gpt-cli.git
cd gpt-cli
pip install .
Add the OpenAI API key to your .bashrc
file (in the root of your home folder).
In this example we use nano, you can use any text editor.
nano ~/.bashrc
export OPENAI_API_KEY=<your_key_here>
Run the tool
gpt
You can also use a gpt.yml
file for configuration. See the Configuration section below.
Make sure to set the OPENAI_API_KEY
environment variable to your OpenAI API key (or put it in the ~/.config/gpt-cli/gpt.yml
file as described below).
usage: gpt [-h] [--no_markdown] [--model MODEL] [--temperature TEMPERATURE] [--top_p TOP_P]
[--log_file LOG_FILE] [--log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
[--prompt PROMPT] [--execute EXECUTE] [--no_stream]
[{dev,general,bash}]
Run a chat session with ChatGPT. See https://github.com/kharvd/gpt-cli for more information.
positional arguments:
{dev,general,bash}
The name of assistant to use. `general` (default) is a generally helpful
assistant, `dev` is a software development assistant with shorter
responses. You can specify your own assistants in the config file
~/.config/gpt-cli/gpt.yml. See the README for more information.
optional arguments:
-h, --help show this help message and exit
--no_markdown Disable markdown formatting in the chat session.
--model MODEL The model to use for the chat session. Overrides the default model defined
for the assistant.
--temperature TEMPERATURE
The temperature to use for the chat session. Overrides the default
temperature defined for the assistant.
--top_p TOP_P The top_p to use for the chat session. Overrides the default top_p defined
for the assistant.
--log_file LOG_FILE The file to write logs to. Supports strftime format codes.
--log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
The log level to use
--prompt PROMPT, -p PROMPT
If specified, will not start an interactive chat session and instead will
print the response to standard output and exit. May be specified multiple
times. Use `-` to read the prompt from standard input. Implies
--no_markdown.
--execute EXECUTE, -e EXECUTE
If specified, passes the prompt to the assistant and allows the user to
edit the produced shell command before executing it. Implies --no_stream.
Use `-` to read the prompt from standard input.
--no_stream If specified, will not stream the response to standard output. This is
useful if you want to use the response in a script. Ignored when the
--prompt option is not specified.
--no_price Disable price logging.
Type :q
or Ctrl-D to exit, :c
or Ctrl-C to clear the conversation, :r
or Ctrl-R to re-generate the last response.
To enter multi-line mode, enter a backslash \
followed by a new line. Exit the multi-line mode by pressing ESC and then Enter.
You can override the model parameters using --model
, --temperature
and --top_p
arguments at the end of your prompt. For example:
> What is the meaning of life? --model gpt-4 --temperature 2.0
The meaning of life is subjective and can be different for diverse human beings and unique-phil ethics.org/cultuties-/ it that reson/bdstals89im3_jrf334;mvs-bread99ef=g22me
The dev
assistant is instructed to be an expert in software development and provide short responses.
$ gpt dev
The bash
assistant is instructed to be an expert in bash scripting and provide only bash commands. Use the --execute
option to execute the commands. It works best with the gpt-4
model.
gpt bash -e "How do I list files in a directory?"
This will prompt you to edit the command in your $EDITOR
it before executing it.
You can configure the assistants in the config file ~/.config/gpt-cli/gpt.yml
. The file is a YAML file with the following structure (see also config.py)
default_assistant: <assistant_name>
markdown: False
openai_api_key: <openai_api_key>
anthropic_api_key: <anthropic_api_key>
log_file: <path>
log_level: <DEBUG|INFO|WARNING|ERROR|CRITICAL>
assistants:
<assistant_name>:
model: <model_name>
temperature: <temperature>
top_p: <top_p>
messages:
- { role: <role>, content: <message> }
- ...
<assistant_name>:
...
You can override the parameters for the pre-defined assistants as well.
You can specify the default assistant to use by setting the default_assistant
field. If you don't specify it, the default assistant is general
. You can also specify the model
, temperature
and top_p
to use for the assistant. If you don't specify them, the default values are used. These parameters can also be overridden by the command-line arguments.
Example:
default_assistant: dev
markdown: True
openai_api_key: <openai_api_key>
assistants:
pirate:
model: gpt-4
temperature: 1.0
messages:
- { role: system, content: "You are a pirate." }
$ gpt pirate
> Arrrr
Ahoy, matey! What be bringing ye to these here waters? Be it treasure or adventure ye seek, we be sailing the high seas together. Ready yer map and compass, for we have a long voyage ahead!
If you are using other models compatible with the OpenAI Python SDK, you can configure them by modifying the openai_base_url
setting in the config file or using the OPENAI_BASE_URL
environment variable .
Example:
openai_base_url: https://your-custom-api-url.com/v1
Use oai-compat:
prefix for the model name to pass non-GPT model names to the API. For example, to chat with Llama3-70b on https://together.ai, use the following command:
OPENAI_API_KEY=$TOGETHER_API_KEY OPENAI_BASE_URL=https://api.together.xyz/v1 gpt general --model oai-compat:meta-llama/Llama-3-70b-chat-hf
The prefix is stripped before sending the request to the API.
To use Claude, you should have an API key from Anthropic (currently there is a waitlist for API access). After getting the API key, you can add an environment variable
export ANTHROPIC_API_KEY=<your_key_here>
or a config line in ~/.config/gpt-cli/gpt.yml
:
anthropic_api_key: <your_key_here>
Now you should be able to run gpt
with --model claude-3-(opus|sonnet|haiku)-<date>
.
gpt --model claude-3-opus-20240229
export GOOGLE_API_KEY=<your_key_here>
or
google_api_key: <your_key_here>
export COHERE_API_KEY=<your_key_here>
or
cohere_api_key: <your_key_here>
For Tasks:
Click tags to check more tools for each tasksFor Jobs:
Alternative AI tools for gpt-cli
Similar Open Source Tools
gpt-cli
gpt-cli is a command-line interface tool for interacting with various chat language models like ChatGPT, Claude, and others. It supports model customization, usage tracking, keyboard shortcuts, multi-line input, markdown support, predefined messages, and multiple assistants. Users can easily switch between different assistants, define custom assistants, and configure model parameters and API keys in a YAML file for easy customization and management.
sage
Sage is a tool that allows users to chat with any codebase, providing a chat interface for code understanding and integration. It simplifies the process of learning how a codebase works by offering heavily documented answers sourced directly from the code. Users can set up Sage locally or on the cloud with minimal effort. The tool is designed to be easily customizable, allowing users to swap components of the pipeline and improve the algorithms powering code understanding and generation.
termax
Termax is an LLM agent in your terminal that converts natural language to commands. It is featured by: - Personalized Experience: Optimize the command generation with RAG. - Various LLMs Support: OpenAI GPT, Anthropic Claude, Google Gemini, Mistral AI, and more. - Shell Extensions: Plugin with popular shells like `zsh`, `bash` and `fish`. - Cross Platform: Able to run on Windows, macOS, and Linux.
openai_trtllm
OpenAI-compatible API for TensorRT-LLM and NVIDIA Triton Inference Server, which allows you to integrate with langchain
code2prompt
code2prompt is a command-line tool that converts your codebase into a single LLM prompt with a source tree, prompt templating, and token counting. It automates generating LLM prompts from codebases of any size, customizing prompt generation with Handlebars templates, respecting .gitignore, filtering and excluding files using glob patterns, displaying token count, including Git diff output, copying prompt to clipboard, saving prompt to an output file, excluding files and folders, adding line numbers to source code blocks, and more. It helps streamline the process of creating LLM prompts for code analysis, generation, and other tasks.
comfy-cli
Comfy-cli is a command line tool designed to facilitate the installation and management of ComfyUI, an open-source machine learning framework. Users can easily set up ComfyUI, install packages, and manage custom nodes directly from the terminal. The tool offers features such as easy installation, seamless package management, custom node management, checkpoint downloads, cross-platform compatibility, and comprehensive documentation. Comfy-cli simplifies the process of working with ComfyUI, making it convenient for users to handle various tasks related to the framework.
HuggingFaceGuidedTourForMac
HuggingFaceGuidedTourForMac is a guided tour on how to install optimized pytorch and optionally Apple's new MLX, JAX, and TensorFlow on Apple Silicon Macs. The repository provides steps to install homebrew, pytorch with MPS support, MLX, JAX, TensorFlow, and Jupyter lab. It also includes instructions on running large language models using HuggingFace transformers. The repository aims to help users set up their Macs for deep learning experiments with optimized performance.
reader
Reader is a tool that converts any URL to an LLM-friendly input with a simple prefix `https://r.jina.ai/`. It improves the output for your agent and RAG systems at no cost. Reader supports image reading, captioning all images at the specified URL and adding `Image [idx]: [caption]` as an alt tag. This enables downstream LLMs to interact with the images in reasoning, summarizing, etc. Reader offers a streaming mode, useful when the standard mode provides an incomplete result. In streaming mode, Reader waits a bit longer until the page is fully rendered, providing more complete information. Reader also supports a JSON mode, which contains three fields: `url`, `title`, and `content`. Reader is backed by Jina AI and licensed under Apache-2.0.
garak
Garak is a vulnerability scanner designed for LLMs (Large Language Models) that checks for various weaknesses such as hallucination, data leakage, prompt injection, misinformation, toxicity generation, and jailbreaks. It combines static, dynamic, and adaptive probes to explore vulnerabilities in LLMs. Garak is a free tool developed for red-teaming and assessment purposes, focusing on making LLMs or dialog systems fail. It supports various LLM models and can be used to assess their security and robustness.
letta
Letta is an open source framework for building stateful LLM applications. It allows users to build stateful agents with advanced reasoning capabilities and transparent long-term memory. The framework is white box and model-agnostic, enabling users to connect to various LLM API backends. Letta provides a graphical interface, the Letta ADE, for creating, deploying, interacting, and observing with agents. Users can access Letta via REST API, Python, Typescript SDKs, and the ADE. Letta supports persistence by storing agent data in a database, with PostgreSQL recommended for data migrations. Users can install Letta using Docker or pip, with Docker defaulting to PostgreSQL and pip defaulting to SQLite. Letta also offers a CLI tool for interacting with agents. The project is open source and welcomes contributions from the community.
garak
Garak is a free tool that checks if a Large Language Model (LLM) can be made to fail in a way that is undesirable. It probes for hallucination, data leakage, prompt injection, misinformation, toxicity generation, jailbreaks, and many other weaknesses. Garak's a free tool. We love developing it and are always interested in adding functionality to support applications.
TypeGPT
TypeGPT is a Python application that enables users to interact with ChatGPT or Google Gemini from any text field in their operating system using keyboard shortcuts. It provides global accessibility, keyboard shortcuts for communication, and clipboard integration for larger text inputs. Users need to have Python 3.x installed along with specific packages and API keys from OpenAI for ChatGPT access. The tool allows users to run the program normally or in the background, manage processes, and stop the program. Users can use keyboard shortcuts like `/ask`, `/see`, `/stop`, `/chatgpt`, `/gemini`, `/check`, and `Shift + Cmd + Enter` to interact with the application in any text field. Customization options are available by modifying files like `keys.txt` and `system_prompt.txt`. Contributions are welcome, and future plans include adding support for other APIs and a user-friendly GUI.
WindowsAgentArena
Windows Agent Arena (WAA) is a scalable Windows AI agent platform designed for testing and benchmarking multi-modal, desktop AI agents. It provides researchers and developers with a reproducible and realistic Windows OS environment for AI research, enabling testing of agentic AI workflows across various tasks. WAA supports deploying agents at scale using Azure ML cloud infrastructure, allowing parallel running of multiple agents and delivering quick benchmark results for hundreds of tasks in minutes.
fabric
Fabric is an open-source framework for augmenting humans using AI. It provides a structured approach to breaking down problems into individual components and applying AI to them one at a time. Fabric includes a collection of pre-defined Patterns (prompts) that can be used for a variety of tasks, such as extracting the most interesting parts of YouTube videos and podcasts, writing essays, summarizing academic papers, creating AI art prompts, and more. Users can also create their own custom Patterns. Fabric is designed to be easy to use, with a command-line interface and a variety of helper apps. It is also extensible, allowing users to integrate it with their own AI applications and infrastructure.
telemetry-airflow
This repository codifies the Airflow cluster that is deployed at workflow.telemetry.mozilla.org (behind SSO) and commonly referred to as "WTMO" or simply "Airflow". Some links relevant to users and developers of WTMO: * The `dags` directory in this repository contains some custom DAG definitions * Many of the DAGs registered with WTMO don't live in this repository, but are instead generated from ETL task definitions in bigquery-etl * The Data SRE team maintains a WTMO Developer Guide (behind SSO)
torchchat
torchchat is a codebase showcasing the ability to run large language models (LLMs) seamlessly. It allows running LLMs using Python in various environments such as desktop, server, iOS, and Android. The tool supports running models via PyTorch, chatting, generating text, running chat in the browser, and running models on desktop/server without Python. It also provides features like AOT Inductor for faster execution, running in C++ using the runner, and deploying and running on iOS and Android. The tool supports popular hardware and OS including Linux, Mac OS, Android, and iOS, with various data types and execution modes available.
For similar tasks
gpt-cli
gpt-cli is a command-line interface tool for interacting with various chat language models like ChatGPT, Claude, and others. It supports model customization, usage tracking, keyboard shortcuts, multi-line input, markdown support, predefined messages, and multiple assistants. Users can easily switch between different assistants, define custom assistants, and configure model parameters and API keys in a YAML file for easy customization and management.
BricksLLM
BricksLLM is a cloud native AI gateway written in Go. Currently, it provides native support for OpenAI, Anthropic, Azure OpenAI and vLLM. BricksLLM aims to provide enterprise level infrastructure that can power any LLM production use cases. Here are some use cases for BricksLLM: * Set LLM usage limits for users on different pricing tiers * Track LLM usage on a per user and per organization basis * Block or redact requests containing PIIs * Improve LLM reliability with failovers, retries and caching * Distribute API keys with rate limits and cost limits for internal development/production use cases * Distribute API keys with rate limits and cost limits for students
For similar jobs
sweep
Sweep is an AI junior developer that turns bugs and feature requests into code changes. It automatically handles developer experience improvements like adding type hints and improving test coverage.
teams-ai
The Teams AI Library is a software development kit (SDK) that helps developers create bots that can interact with Teams and Microsoft 365 applications. It is built on top of the Bot Framework SDK and simplifies the process of developing bots that interact with Teams' artificial intelligence capabilities. The SDK is available for JavaScript/TypeScript, .NET, and Python.
ai-guide
This guide is dedicated to Large Language Models (LLMs) that you can run on your home computer. It assumes your PC is a lower-end, non-gaming setup.
classifai
Supercharge WordPress Content Workflows and Engagement with Artificial Intelligence. Tap into leading cloud-based services like OpenAI, Microsoft Azure AI, Google Gemini and IBM Watson to augment your WordPress-powered websites. Publish content faster while improving SEO performance and increasing audience engagement. ClassifAI integrates Artificial Intelligence and Machine Learning technologies to lighten your workload and eliminate tedious tasks, giving you more time to create original content that matters.
chatbot-ui
Chatbot UI is an open-source AI chat app that allows users to create and deploy their own AI chatbots. It is easy to use and can be customized to fit any need. Chatbot UI is perfect for businesses, developers, and anyone who wants to create a chatbot.
BricksLLM
BricksLLM is a cloud native AI gateway written in Go. Currently, it provides native support for OpenAI, Anthropic, Azure OpenAI and vLLM. BricksLLM aims to provide enterprise level infrastructure that can power any LLM production use cases. Here are some use cases for BricksLLM: * Set LLM usage limits for users on different pricing tiers * Track LLM usage on a per user and per organization basis * Block or redact requests containing PIIs * Improve LLM reliability with failovers, retries and caching * Distribute API keys with rate limits and cost limits for internal development/production use cases * Distribute API keys with rate limits and cost limits for students
uAgents
uAgents is a Python library developed by Fetch.ai that allows for the creation of autonomous AI agents. These agents can perform various tasks on a schedule or take action on various events. uAgents are easy to create and manage, and they are connected to a fast-growing network of other uAgents. They are also secure, with cryptographically secured messages and wallets.
griptape
Griptape is a modular Python framework for building AI-powered applications that securely connect to your enterprise data and APIs. It offers developers the ability to maintain control and flexibility at every step. Griptape's core components include Structures (Agents, Pipelines, and Workflows), Tasks, Tools, Memory (Conversation Memory, Task Memory, and Meta Memory), Drivers (Prompt and Embedding Drivers, Vector Store Drivers, Image Generation Drivers, Image Query Drivers, SQL Drivers, Web Scraper Drivers, and Conversation Memory Drivers), Engines (Query Engines, Extraction Engines, Summary Engines, Image Generation Engines, and Image Query Engines), and additional components (Rulesets, Loaders, Artifacts, Chunkers, and Tokenizers). Griptape enables developers to create AI-powered applications with ease and efficiency.