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

Publish to PyPI

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.2.tar.gz (11.7 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.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for konijima_gpt_cli-1.1.2.tar.gz
Algorithm Hash digest
SHA256 dfd7a80b865f934aa33496dc49edf20f26bbf6366b55696d163262f0ed44eae7
MD5 a905efaf44550d44f492b2b7206370b6
BLAKE2b-256 f7f3a1a57dde8d08aa3ed29ab0fbe444a80cebfb998198db4038c06a950e76a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for konijima_gpt_cli-1.1.2.tar.gz:

Publisher: publish.yml on Konijima/gpt-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for konijima_gpt_cli-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a8ba40bdacc2e1a3e63dc009ea823f4cfcdd91323a61a17ba256a0f69a58324
MD5 0da4c5ff50d9bf61e7ad89dc69769ef4
BLAKE2b-256 c7dd963495fba2e772b6305b08650215ac673bd60bf25815f8ce9501b9602029

See more details on using hashes here.

Provenance

The following attestation bundles were made for konijima_gpt_cli-1.1.2-py3-none-any.whl:

Publisher: publish.yml on Konijima/gpt-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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