Skip to main content

An interactive AI chatbot for the command line - DSRS

Project description

DSRS CLI Chat 🚀

A lightweight, feature-rich, interactive AI chatbot for your command line, powered by OpenAI-compatible APIs.

Features

  • Interactive Chat: Engage in conversations with an AI model directly from your terminal.
  • OpenAI Compatible: Connects to any OpenAI-compatible API endpoint.
  • Streaming Responses: Watch the AI's response appear in real-time.
  • Rich Output: Uses rich for beautiful Markdown rendering, including code blocks with syntax highlighting.
  • Advanced Input: Uses prompt_toolkit for:
  • Multi-line input (easy pasting).
  • Persistent command history (Up/Down arrows).
  • Input clearing (Ctrl+U).
  • Tab completion for model selection.
  • Interruptible Generation: Stop the AI mid-response with Ctrl+X.
  • Model Selection: Choose from available models provided by the API endpoint.
  • Custom System Prompt: View and modify the system prompt guiding the AI's behavior.
  • Credential Management: Load API Key and Base URL securely from a .env file or enter them manually.
  • Useful Commands: clear, restart, model, system, instructions, exit/quit.
  • Exit Summary: Displays the final context sent to the AI and its last response upon quitting.
  • Cross-Platform: Designed to work on Linux, macOS, and Windows.

Requirements

  • Python 3.7+
  • Pip (Python package installer)
  • An API Key and Base URL for an OpenAI-compatible API endpoint.

Installation

To install, just run:

pip install dsrs-cli

Configuration

The script needs your API Key and the Base URL for the AI service.

  • Using .env file (Recommended):

  • Create a file named .env in the same directory where you run the script (or where dsrs_cli.py is located if
    installing).

  • Add the following lines, replacing the placeholders with your actual credentials:

    OPENAI_API_KEY=...
    BASE_URL=...
    
  • When you run the script, choose 'y' when asked "Load API Key and Base URL from .env file?".

  • Manual Input:

  • If you don't use a .env file or it's missing credentials, the script will prompt you to enter the API Key
    (hidden) and Base URL securely when it starts.

Usage

After installing, run:

dsrs-chat                                                                                                                  

Interacting with the Chat:

  • Type your message. For multi-line input, press Esc then Enter (or your terminal's default for submitting multi-line).
  • Commands:
  • instructions: Show the welcome message and commands again.
  • model: Select a different AI model from the available list.
  • system: View the current system prompt and optionally change it.
  • clear: Clear the terminal screen.
  • restart: Restart the chat application.
  • exit or quit: Exit the chat application.
  • Shortcuts:
  • Ctrl+X: Interrupt the AI while it's generating a response.
  • Ctrl+U: Clear the current input line.
  • Up/Down Arrows (on empty line): Navigate through input history.
  • Ctrl+C: Exit the application immediately.
  • Ctrl+D (EOF): Exit the application gracefully.

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

dsrs_cli-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

dsrs_cli-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file dsrs_cli-0.1.0.tar.gz.

File metadata

  • Download URL: dsrs_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for dsrs_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23247d67d68a5576d5d616baa20664d8c3afb926b331d9e8d6d40c5fec0eaecd
MD5 9e461e0918de4da55d039ee134e0cf5d
BLAKE2b-256 d5bab9a1e7c0292edc156455a0a6ae6f0c8bf4fd788e0516490e0f1db511a790

See more details on using hashes here.

File details

Details for the file dsrs_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dsrs_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for dsrs_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a4b072792a74e6a8e9b87e83a2987dc729fcb13cfb84fad20600becc7ba58d2
MD5 1b73581b697c8c80821a033f69684bd0
BLAKE2b-256 6def475fdabd4303a1e0bbb3507f7fbca026cf20a5df015272ee6cc8c4f3b80a

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