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.1.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.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dsrs_cli-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 225c48276f73d54325278a4dafb81e40a5f6efa23c950cd0cfff9354b13cddf8
MD5 68da2862cc99014975b38c5c104c09ec
BLAKE2b-256 3506cee91267ae8df06f7ab2306dfccb523edd76921dd3fab0a63e726fe16b99

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dsrs_cli-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee8a7bdbc1d2e1844ce21aa3f6fdc95580be5da3c1426b7c24f4a90a75eee2ad
MD5 b80c522f7fa7f40424758aa92b35d154
BLAKE2b-256 c717d073be8364cbc67fe0124e4ae0b778a4a4a45204677d0b461fd812058f8e

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