Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

🧠 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.

Metadata

Release files for konijima-gpt-cli 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for konijima-gpt-cli 1.1.2
File Size Uploaded
konijima_gpt_cli-1.1.2.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for konijima-gpt-cli 1.1.2
File Interpreter ABI Platform
konijima_gpt_cli-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / konijima_gpt_cli-1.1.2.tar.gz

Download URL konijima_gpt_cli-1.1.2.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dfd7a80b865f934aa33496dc49edf20f26bbf6366b55696d163262f0ed44eae7
BLAKE2b-256 checksum
How to use checksums
f7f3a1a57dde8d08aa3ed29ab0fbe444a80cebfb998198db4038c06a950e76a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2025.

Transparency log

Release files / konijima_gpt_cli-1.1.2-py3-none-any.whl

Download URL konijima_gpt_cli-1.1.2-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a8ba40bdacc2e1a3e63dc009ea823f4cfcdd91323a61a17ba256a0f69a58324
BLAKE2b-256 checksum
How to use checksums
c7dd963495fba2e772b6305b08650215ac673bd60bf25815f8ce9501b9602029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page