gitmyhub

llm-cli

Python ★ 11 updated 1mo ago

Command-line interface for querying large language models

A small Python CLI for sending prompts to LLMs from the terminal, with model picking, streaming, stdin piping, and OpenAI, Anthropic, or Ollama backends.

PythonpipOpenAIAnthropicOllamasetup: easycomplexity 2/5

This project is a small command line tool, written in Python, that lets you send prompts to large language models without leaving your terminal. You install it with pip install llm-cli, then call it as llm-cli followed by a quoted prompt. The README shows examples such as asking it to explain recursion in Python, write a haiku about debugging, generate test data, or simply answer what is 2 plus 2.

The tool offers a set of flags for changing how the request is made. You can pick a model with the model flag, adjust randomness with temperature on a 0.0 to 2.0 scale, cap reply length with max tokens, stream the answer token by token, read the prompt from standard input by piping a file in, or use a multi line input mode that ends on Ctrl D. A system flag lets you set a system prompt, and the API key can be passed as a flag or read from the LLM_API_KEY environment variable.

Defaults can be set in two ways. Three environment variables, LLM_API_KEY, LLM_DEFAULT_MODEL, and LLM_API_BASE, control credentials, the default model, and the base URL of the API. The same values, along with temperature and max tokens, can also live in a JSON config file at the tilde slash .llm-cli slash config.json path.

The README lists three model families it claims to support: OpenAI models gpt-4 and gpt-3.5-turbo, Anthropic models claude-3-opus and claude-3-sonnet, and local models served through Ollama, namely llama2 and mistral. The project is released under the MIT license and the README says pull requests are welcome but to open an issue first for big changes.

Where it fits