Skip to main content

A powerful CLI for chatting with AI models through OpenRouter

Project description

๐Ÿค– OrChat

OrChat Interface

PyPI version License: MIT Python 3.9+ Downloads GitHub Stars

๐Ÿš€ Installation โ€ข โœจ Features โ€ข ๐Ÿ’ฌ Chat Commands โ€ข ๐Ÿ“ File Attachment โ€ข ๐Ÿง  Thinking Mode โ€ข โš™๏ธ Configuration โ€ข ๐Ÿ” Troubleshooting โ€ข ๐Ÿค Contributing

A powerful CLI for chatting with AI models through OpenRouter with streaming responses, token tracking, auto-update checking, multi-line input, and extensive customization options.

โœจ Features

๐Ÿ”— Core Features
  • Universal Model Access: Connect to any AI model available on OpenRouter with dynamic model retrieval
  • Interactive Chat: Enjoy a smooth conversation experience with real-time streaming responses
  • Rich Markdown Rendering: View formatted text, code blocks, tables and more directly in your terminal
  • Performance Analytics: Track token usage, response times, and total cost for efficiency monitoring (now with accurate API-based token counting)
  • Command Auto-completion: Enhanced user experience with intelligent command suggestions and prompt history navigation
  • Prompt History Navigation: Use โ†‘/โ†“ arrow keys to navigate through previous prompts and Ctrl+R for history search
  • Pricing Display: Real-time pricing information displayed during active chat sessions
  • Auto-Update System: Automatic update checking at startup with pip integration
  • Multi-line Input Support: Compose multi-paragraph messages with Esc+Enter and visual feedback
๐Ÿ“Ž File & Media Support
  • Smart File Picker: Attach files anywhere in your message using # (e.g., analyze #myfile.py)
  • Interactive File Browser: Browse files with icons, sizes, and directory navigation in a popup interface
  • Multimodal Support: Share images and various file types with compatible AI models
  • Enhanced File Processing: Improved file attachment with better error handling and path support
๐Ÿง  Advanced Features
  • Smart Thinking Mode: See the AI's reasoning process with compatible models
  • Multiple Export Formats: Save conversations as Markdown, HTML, JSON, TXT, or PDF
  • Smart Context Management: Automatically manages conversation history to stay within token limits
  • Customizable Themes: Choose from different visual themes for your terminal
โŒจ๏ธ Interactive Input Features
  • Multi-line Input: Use Esc+Enter to toggle multi-line mode, with status indicator and seamless toggling
  • Command History Navigation: Press โ†‘/โ†“ arrow keys to cycle through previous prompts and commands
  • History Search: Use Ctrl+R to search through your prompt history with keywords
  • Automatic Command Completion: Start typing "/" and command suggestions appear instantly - no Tab key needed!
  • Auto-Suggest from History: Previous commands and prompts appear as grey suggestions as you type
  • Intelligent File Picker: Use # anywhere in your message for file selection with auto-completion and browser popup

๐Ÿ’ก How Auto-Completion Works:

  • Type / โ†’ All available commands appear automatically
  • Type /c โ†’ Filters to commands starting with 'c' (clear, cls, clear-screen, etc.)
  • Type /temp โ†’ Shows /temperature command
  • Type /think โ†’ Shows /thinking and /thinking-mode commands
  • No Tab key required - completions appear as you type!

๐Ÿ’ก How File Picker Works:

  • Type # anywhere in your message to open the file picker
  • Choose files interactively (with icons for file types)
  • Insert filenames naturally into your prompt, e.g., examine #test.py and check for errors
  • File picker works anywhere in your message, not just at the beginning

๐Ÿš€ Installation

๐Ÿ“ฆ Installation Methods

From PyPI (Recommended)

pip install orchat
# Run the application
orchat

From Source

git clone https://github.com/oop7/OrChat.git
pip install -r requirements.txt
python main.py
๐Ÿ“‹ Prerequisites
  • Python 3.7 or higher
  • An OpenRouter API key (get one at OpenRouter.ai)
  • Required packages: in requirements.txt
๐Ÿ Getting Started
  1. Install OrChat using one of the methods above
  2. Run the setup wizard
    • if you follow from source PyPI:
      orchat --setup
      
    • if you follow from source method:
      python main.py --setup
      
  3. Enter your OpenRouter API key when prompted
  4. Select your preferred AI model and configure settings
  5. Start chatting!
๐Ÿช› Add-Ons

FZF fuzzy search (Enhanced Model Selection)

  1. Install fzf and pyfzf

  2. Ensure fzf is in your path

  3. From now on, the model selection will use fzf for powerful fuzzy search and filtering capabilities!

Note: If fzf is not installed, OrChat will automatically fall back to standard model selection.

โš™๏ธ Configuration

๐Ÿ”ง Configuration Methods

OrChat can be configured in multiple ways:

  1. Setup Wizard: Run python main.py --setup for interactive configuration
  2. Config File: Edit the config.ini file in the application directory
  3. Environment Variables: Create a .env file with your configuration
  4. System Environment Variables: Set environment variables directly in your system (recommended for security)

Enhanced Environment Support: OrChat now supports system/user environment variables, removing the strict requirement for .env files.

๐Ÿ“„ Configuration Examples

Example .env file:

OPENROUTER_API_KEY=your_api_key_here

Example config.ini structure:

[API]
OPENROUTER_API_KEY = your_api_key_here

[SETTINGS]
MODEL = anthropic/claude-3-opus
TEMPERATURE = 0.7
SYSTEM_INSTRUCTIONS = You are a helpful AI assistant.
THEME = default
MAX_TOKENS = 8000
AUTOSAVE_INTERVAL = 300
STREAMING = True
THINKING_MODE = False
๐Ÿ–ฅ๏ธ Command-Line Options
  • --setup: Run the setup wizard
  • --model MODEL: Specify the model to use (e.g., --model "anthropic/claude-3-opus")
  • --task {creative,coding,analysis,chat}: Optimize for a specific task type
  • --image PATH: Analyze an image file

๐Ÿ’ฌ Chat Commands

Command Description
/help Show available commands
/exit Exit the chat
/quit Exit the chat
/new Start a new conversation
/clear Clear conversation history
/cls or /clear-screen Clear the terminal screen
/save [format] Save conversation (formats: md, html, json, txt, pdf)
/model Change the AI model
/temperature <0.0-2.0> Adjust temperature setting
/system View or change system instructions
/tokens Show token usage statistics (now API-accurate)
/speed Show response time statistics
/theme <theme> Change the color theme (default, dark, light, hacker)
/thinking Show last AI thinking process
/thinking-mode Toggle thinking mode on/off
/about Show information about OrChat
/update Check for updates
/settings View current settings

๐Ÿ“ File Attachment

๐Ÿ“Ž Basic Usage

Attach files naturally in your messages using the smart file picker:

analyze #path/to/your/file.ext for issues
examine #script.py and explain its logic
  • Use # anywhere in your message to open the file picker popup
โœจ Enhanced Features
  • Intelligent File Picker: Auto-completion, icons, file sizes, and directory navigation
  • Quoted Path Support: Handles file paths with spaces using quotes
  • Better Error Handling: Improved error messages and usage examples
  • File Preview: Shows file metadata and preview before processing
  • Security Validation: Built-in file size and type validation (10MB limit)
๐Ÿ“‹ Supported File Types
  • Images: JPG, PNG, GIF, WEBP, BMP (displayed visually with multimodal models)
  • Code Files: Python, JavaScript, Java, C++, TypeScript, Swift, etc. (with syntax highlighting)
  • Text Documents: TXT, MD, CSV (full content displayed)
  • Data Files: JSON, XML (displayed with formatting)
  • Web Files: HTML, CSS (formatted display)
  • Archives: ZIP, TAR, GZ, RAR (basic metadata support)

๐Ÿง  Thinking Mode

๐ŸŽฏ Basic Usage

OrChat can display the AI's reasoning process with enhanced thinking mode:

/thinking-mode       # Toggle thinking mode on/off
/thinking            # Show the most recent thinking process

This feature allows you to see how the AI approached your question before giving its final answer. Auto Thinking Mode automatically enables this feature when you select models with reasoning support.

โœจ Enhanced Features
  • Improved Detection: Better extraction of thinking content from model responses
  • Model Compatibility: Automatic handling of models that don't support thinking mode
  • Visual Indicators: Clear status indicators showing if thinking mode is enabled
  • Flexible Setup: Option to enable/disable during model selection

๐ŸŽจ Themes

๐ŸŽจ Available Themes

Change the visual appearance with the /theme command:

  • default: Blue user, green assistant
  • dark: Cyan user, magenta assistant
  • light: Blue user, green assistant with lighter colors
  • hacker: Matrix-inspired green text on black

๐Ÿ“Š Token Management

๐Ÿ“Š Smart Context Management

OrChat intelligently manages conversation context to keep within token limits:

  • Automatically trims old messages when approaching limits
  • Displays comprehensive token usage statistics including total tokens and cost tracking
  • Shows real-time pricing information during active sessions
  • Displays total cost tracking across conversations
  • Allows manual clearing of context with /clear

๐Ÿ”„ Updates

๐Ÿ”„ Version Management

Check for updates with the /update command to see if a newer version is available.

๐Ÿ” Troubleshooting

๐Ÿ” Common Issues & Solutions
  • API Key Issues: Ensure your OpenRouter API key is correctly set in config.ini, .env file, or system environment variables. OrChat will prompt for re-entry if an incorrect key is detected
  • Insufficient Account Credit: If you receive a 402 error, check your OpenRouter account balance and add funds as needed
  • File Path Problems: When using /attach or /upload, use quotes for paths with spaces and ensure correct path format for your OS
  • Model Compatibility: Some features like thinking mode only work with specific models
  • Command Usage: Remember that /upload and /attach can be used anywhere in your message for flexibility

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

๐Ÿ™ Acknowledgments

๐Ÿ™ Special Thanks
  • OpenRouter for providing unified API access to AI models
  • Rich for the beautiful terminal interface
  • All contributors and users who provide feedback and help improve OrChat

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

orchat-1.3.0.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

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

orchat-1.3.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file orchat-1.3.0.tar.gz.

File metadata

  • Download URL: orchat-1.3.0.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for orchat-1.3.0.tar.gz
Algorithm Hash digest
SHA256 396a8231860132ec51b8465eaeabac7187d41c4bfea8acad45f559beda551c8c
MD5 f9e869b5f532afb3ad7af2944874a4dd
BLAKE2b-256 097dce9ab8f234d009993dfbf88e2bf6b4f35675ee5899e5d5c7221dc382396f

See more details on using hashes here.

File details

Details for the file orchat-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: orchat-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for orchat-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfa0f9da5eae958e672b8d6c6b3ed9d3550d27ec37ee70e8006e8824fb6c9b20
MD5 b64e6e8215f4cd3dc8cf30d37e3d6d19
BLAKE2b-256 d24b3c92cc429442a194ffaf90c3f5830a6901a8a95155f6cae4edf80603c3a0

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