Skip to main content

GPT CLI — A conversational assistant with memory, config, and logging features.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

🧠 GPT CLI Tool with Persistent Memory and Streaming

A terminal-based GPT assistant powered by the OpenAI API, featuring:

  • 🔁 Persistent memory across sessions with summarization
  • 🌊 Streaming output (optional)
  • 🧾 Command history and logging
  • 🧠 Customizable prompt and model
  • 🔐 Secure .env configuration

📦 Features

  • Conversational memory with summarization after 20 messages
  • Markdown-formatted input/output in terminal
  • Command history with autocompletion
  • Optional streaming mode (prints as it's generated)
  • Command-line and one-shot mode
  • Log file support for auditing

🚀 Installation

Install the GPT CLI via pip or pipx. Requires Python 3.8+.

Using PyPI

pip install konijima-gpt-cli

Using pipx (recommended)

pipx install konijima-gpt-cli

From GitHub (install directly from source)

# Install directly from the GitHub repo to avoid PyPI conflicts
pip install git+https://github.com/Konijima/gpt-cli.git#egg=konijima-gpt-cli
# or with pipx
pipx install git+https://github.com/Konijima/gpt-cli.git#egg=konijima-gpt-cli

Development Installation

git clone https://github.com/Konijima/gpt-cli.git
cd gpt-cli
pip install .

Update

pip install --upgrade konijima-gpt-cli
# or
pipx upgrade konijima-gpt-cli

Uninstallation

pip uninstall konijima-gpt-cli
# or
pipx uninstall konijima-gpt-cli

🛠️ Environment Setup

A .env file is required to store your API key and configuration.

touch ~/.gpt-cli/.env

Sample .env File

OPENAI_API_KEY=your-api-key-here
OPENAI_MODEL=gpt-4o
OPENAI_DEFAULT_PROMPT=You are a helpful CLI assistant.
OPENAI_LOGFILE=~/.gpt.log
OPENAI_TEMPERATURE=0.5
OPENAI_MAX_TOKENS=4096
OPENAI_MAX_SUMMARY_TOKENS=2048
OPENAI_MEMORY_PATH=~/.gpt_memory.json
OPENAI_STREAM_ENABLED=false

🔧 Usage

After installation, you can use the gpt command globally.

Interactive Mode

gpt

You’ll enter a REPL-like interface:

🧠 GPT CLI is ready. Type your question or 'exit' to quit.

One-Shot Mode

gpt "Translate 'hello' to French"

From Pipe Input

echo "Write a haiku about the ocean" | gpt

Reset Memory

gpt --reset

This clears all saved memory and summaries, then exits.

Edit Environment Configuration

gpt --env

Opens your .env file in your default terminal editor (e.g., nano, vim, or set via $EDITOR).

Uninstall

gpt --uninstall

This command will completely remove the GPT CLI, including the .env file and virtual environment under ~/.gpt-cli, as well as the global gpt command from ~/.local/bin.


🔐 Environment Variables (Full Reference)

Variable Description Default
OPENAI_API_KEY Required. Your OpenAI API key
OPENAI_MODEL Model to use (gpt-4o, gpt-3.5-turbo, etc.) gpt-4o
OPENAI_DEFAULT_PROMPT System prompt used at the start of each session (empty)
OPENAI_LOGFILE File path to log all interactions ~/.gpt.log
OPENAI_TEMPERATURE Sampling temperature (creativity vs determinism) 0.5
OPENAI_MAX_TOKENS Maximum tokens per response 4096
OPENAI_MAX_SUMMARY_TOKENS Max tokens when summarizing recent interactions 2048
OPENAI_MEMORY_PATH Path to memory file for summary + recent messages ~/.gpt_memory.json
OPENAI_STREAM_ENABLED Enable streaming output (live typing) false

📝 Log Format

If OPENAI_LOGFILE is set, all prompts and responses are saved:

[2025-04-15 15:51:51] Prompt:
Hello there

Response:
Hello there again! What would you like to explore or discuss today?
--------------------------------------------------------------------------------

🧹 Memory

Memory consists of:

  • A rolling summary of conversation
  • The 10 most recent messages

When 20 messages accumulate, the tool summarizes them into the context summary.

To reset memory:

gpt --reset

❓ Troubleshooting

  • Missing API key: Ensure OPENAI_API_KEY is set in .env
  • Client failed to initialize: Check internet and API credentials
  • 💭 Too many tokens: Try a smaller input or enable summarization

🧪 Example Output

You:
Write a joke about servers

GPT:
Why did the server go to therapy?

Because it had too many unresolved requests.

📄 License

MIT License


✨ Credits

Built with ❤️ by Konijima and OpenAI’s GPT models.

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

konijima_gpt_cli-1.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

konijima_gpt_cli-1.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file konijima_gpt_cli-1.1.0.tar.gz.

File metadata

  • Download URL: konijima_gpt_cli-1.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for konijima_gpt_cli-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8023a7212f027dd3e2b33d409c69ae5d472842c84b185afb5a914cfec54b333c
MD5 2a1fd7527c146c62969be20943f34019
BLAKE2b-256 da6a22b434ad7321cda268206505ad9dd92f6595b3f2a65cd426bc21fe45960a

See more details on using hashes here.

File details

Details for the file konijima_gpt_cli-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for konijima_gpt_cli-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 998dee3ebcd393354032d3a7bf13ad4dc2fb79498ffe38c55ef65d8ee137d228
MD5 b80252bacee1b26797872decb980e30f
BLAKE2b-256 be52676c26580bc1bcf96ec1c6cbaf7f97241be7e10f57d3904a09a806385778

See more details on using hashes here.

Supported by

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