Compare commits
8 Commits
63722aabf9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 459f6f8165 | |||
| 45877b911c | |||
| 2da56b905d | |||
| 68eb9e11fc | |||
| 2b54b8974b | |||
| 82b9fc9251 | |||
| c7ebf89ae6 | |||
| a51d1f65e2 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,4 +22,5 @@ Pipfile.lock # Consider if you want to include or exclude
|
||||
._*
|
||||
*~.nib
|
||||
*~.xib
|
||||
README.md.old
|
||||
README.md.old
|
||||
oai.zip
|
||||
261
README.md
261
README.md
@@ -1,63 +1,228 @@
|
||||
# oAI Chat App
|
||||
# oAI - OpenRouter AI Chat
|
||||
|
||||
A command-line interface for chatting with AI models via OpenRouter, supporting model selection, streaming responses, file attachments, credit tracking, and configurable settings.
|
||||
A terminal-based chat interface for OpenRouter API with conversation management, cost tracking, and rich formatting.
|
||||
|
||||
## Description
|
||||
|
||||
oAI is a command-line chat application that provides an interactive interface to OpenRouter's AI models. It features conversation persistence, file attachments, export capabilities, and detailed session metrics.
|
||||
|
||||
## Features
|
||||
|
||||
- Select and switch between OpenRouter models
|
||||
- Streaming or buffered responses
|
||||
- Attach images and text files to messages
|
||||
- View credit usage and balance
|
||||
- Set persistent default model
|
||||
- Keyboard shortcuts and history
|
||||
- Interactive chat with multiple AI models via OpenRouter
|
||||
- Model selection with search functionality
|
||||
- Conversation save/load/export (Markdown, JSON, HTML)
|
||||
- File attachment support (code files and images)
|
||||
- Session cost tracking and credit monitoring
|
||||
- Rich terminal formatting with syntax highlighting
|
||||
- Persistent command history
|
||||
- Configurable system prompts and token limits
|
||||
- SQLite-based configuration and conversation storage
|
||||
|
||||
## Installation
|
||||
## Requirements
|
||||
|
||||
Requires Python 3.8+. Download the repository. Install dependencies:
|
||||
|
||||
```bash
|
||||
pip install typer rich openrouter pyperclip requests prompt_toolkit
|
||||
```
|
||||
|
||||
Or use :
|
||||
|
||||
```bash
|
||||
pip install -r requiremnets.txt
|
||||
```
|
||||
|
||||
For convience you can move the application to a folder in you `$PATH` and rename it to just `oai` .
|
||||
|
||||
## Usage
|
||||
|
||||
Run the app and interact via commands:
|
||||
|
||||
```bash
|
||||
python oai_chat.py
|
||||
```
|
||||
|
||||
Example session:
|
||||
|
||||
```
|
||||
Welcome to oAI!
|
||||
You> /model gpt
|
||||
(Shows table of GPT models)
|
||||
Enter model number: 1
|
||||
Selected: GPT-4o (openai/gpt-4o)
|
||||
|
||||
You> Hello, how are you?
|
||||
Streaming response... (Press Ctrl+C to cancel)
|
||||
Hello! I'm doing great...
|
||||
```
|
||||
|
||||
For full commands, use `/help` in the app.
|
||||
- Python 3.7 or higher
|
||||
- OpenRouter API key (get one at https://openrouter.ai)
|
||||
|
||||
## Screenshot
|
||||
|
||||
[<img src="https://gitlab.pm/rune/oai/raw/branch/main/images/screenshot_01.png">](https://gitlab.pm/rune/oai/src/branch/main/README.md)
|
||||
|
||||
Screenshot of `/help` screen.
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Install Dependencies
|
||||
|
||||
Use the included `requirements.txt` file to install the dependencies:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 2. Make the Script Executable
|
||||
|
||||
```bash
|
||||
chmod +x oai.py
|
||||
```
|
||||
|
||||
### 3. Copy to PATH
|
||||
|
||||
Copy the script to a directory in your `$PATH` environment variable. Common locations include:
|
||||
|
||||
```bash
|
||||
# Option 1: System-wide (requires sudo)
|
||||
sudo cp oai.py /usr/local/bin/oai
|
||||
|
||||
# Option 2: User-local (recommended)
|
||||
mkdir -p ~/.local/bin
|
||||
cp oai.py ~/.local/bin/oai
|
||||
|
||||
# Add to PATH if not already (add to ~/.bashrc or ~/.zshrc)
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
```
|
||||
|
||||
### 4. Verify Installation
|
||||
|
||||
```bash
|
||||
oai
|
||||
```
|
||||
|
||||
### 5. Alternative Installation (for *nix systems)
|
||||
|
||||
If you have issues with the above method you can add an alias in your `.bashrc`, `.zshrc` etc.
|
||||
|
||||
```bash
|
||||
alias oai='python3 <path to your file>'
|
||||
```
|
||||
|
||||
On first run, you will be prompted to enter your OpenRouter API key.
|
||||
|
||||
## Usage
|
||||
|
||||
### Starting the Application
|
||||
|
||||
```bash
|
||||
oai
|
||||
```
|
||||
|
||||
### Basic Commands
|
||||
|
||||
```
|
||||
/help Show all available commands
|
||||
/model Select an AI model
|
||||
/config api Set OpenRouter API key
|
||||
exit Quit the application
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
All configuration is stored in `~/.config/oai/`:
|
||||
- `oai_config.db` - SQLite database for settings and conversations
|
||||
- `oai.log` - Application log file
|
||||
- `history.txt` - Command history
|
||||
|
||||
### Common Workflows
|
||||
|
||||
**Select a Model:**
|
||||
```
|
||||
/model
|
||||
```
|
||||
|
||||
**Paste from clipboard:**
|
||||
Paste and send content to model
|
||||
```
|
||||
/paste
|
||||
```
|
||||
|
||||
Paste with prompt and send content to model
|
||||
```
|
||||
/paste Analyze this text
|
||||
```
|
||||
|
||||
**Start Chatting:**
|
||||
```
|
||||
You> Hello, how are you?
|
||||
```
|
||||
|
||||
**Attach Files:**
|
||||
```
|
||||
You> Debug this code @/path/to/script.py
|
||||
You> Analyze this image @/path/to/image.png
|
||||
```
|
||||
|
||||
**Save Conversation:**
|
||||
```
|
||||
/save my_conversation
|
||||
```
|
||||
|
||||
**Export to File:**
|
||||
```
|
||||
/export md notes.md
|
||||
/export json backup.json
|
||||
/export html report.html
|
||||
```
|
||||
|
||||
**View Session Stats:**
|
||||
|
||||
```
|
||||
/stats
|
||||
/credits
|
||||
```
|
||||
|
||||
**Prevous commands input:**
|
||||
|
||||
Use the up/down arrows to see earlier `/`commands and earlier input to model and `<enter>` to execute the same command or resend the same input.
|
||||
|
||||
## Command Reference
|
||||
|
||||
Use `/help` within the application for a complete command reference organized by category:
|
||||
- Session Commands
|
||||
- Model Commands
|
||||
- Configuration
|
||||
- Token & System
|
||||
- Conversation Management
|
||||
- Monitoring & Stats
|
||||
- File Attachments
|
||||
|
||||
## Configuration Options
|
||||
|
||||
- API Key: `/config api`
|
||||
- Base URL: `/config url`
|
||||
- Streaming: `/config stream on|off`
|
||||
- Default Model: `/config model`
|
||||
- Cost Warning: `/config costwarning <amount>`
|
||||
- Max Token Limit: `/config maxtoken <value>`
|
||||
|
||||
## File Support
|
||||
|
||||
**Supported Code Extensions:**
|
||||
.py, .js, .ts, .cs, .java, .c, .cpp, .h, .hpp, .rb, .ruby, .php, .swift, .kt, .kts, .go, .sh, .bat, .ps1, .R, .scala, .pl, .lua, .dart, .elm, .xml, .json, .yaml, .yml, .md, .txt
|
||||
|
||||
**Image Support:**
|
||||
Any image format with proper MIME type (PNG, JPEG, GIF, etc.)
|
||||
|
||||
## Data Storage
|
||||
|
||||
- Configuration: `~/.config/oai/oai_config.db`
|
||||
- Logs: `~/.config/oai/oai.log`
|
||||
- History: `~/.config/oai/history.txt`
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [MIT License](https://opensource.org/licenses/MIT).
|
||||
MIT License
|
||||
|
||||
Author: Rune Olsen
|
||||
Copyright (c) 2024 Rune Olsen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
Full license: https://opensource.org/licenses/MIT
|
||||
|
||||
## Author
|
||||
|
||||
**Rune Olsen**
|
||||
|
||||
Blog: https://blog.rune.pm
|
||||
|
||||
## Version
|
||||
|
||||
1.0
|
||||
|
||||
## Support
|
||||
|
||||
For issues, questions, or contributions, visit https://iurl.no/oai and create an issue.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 297 KiB After Width: | Height: | Size: 318 KiB |
@@ -1,16 +1,37 @@
|
||||
annotated-types==0.7.0
|
||||
anyio==4.9.0
|
||||
certifi==2025.1.31
|
||||
distro==1.9.0
|
||||
h11==0.14.0
|
||||
httpcore==1.0.7
|
||||
anyio==4.11.0
|
||||
beautifulsoup4==4.14.2
|
||||
charset-normalizer==3.4.4
|
||||
click==8.3.1
|
||||
docopt==0.6.2
|
||||
h11==0.16.0
|
||||
httpcore==1.0.9
|
||||
httpx==0.28.1
|
||||
idna==3.10
|
||||
jiter==0.9.0
|
||||
openai==1.71.0
|
||||
pydantic==2.11.2
|
||||
pydantic_core==2.33.1
|
||||
idna==3.11
|
||||
latex2mathml==3.78.1
|
||||
loguru==0.7.3
|
||||
markdown-it-py==4.0.0
|
||||
markdown2==2.5.4
|
||||
mdurl==0.1.2
|
||||
natsort==8.4.0
|
||||
openrouter==0.0.19
|
||||
pipreqs==0.4.13
|
||||
prompt_toolkit==3.0.52
|
||||
Pygments==2.19.2
|
||||
pyperclip==1.11.0
|
||||
python-dateutil==2.9.0.post0
|
||||
python-magic==0.4.27
|
||||
PyYAML==6.0.3
|
||||
requests==2.32.5
|
||||
rich==14.2.0
|
||||
shellingham==1.5.4
|
||||
six==1.17.0
|
||||
sniffio==1.3.1
|
||||
soupsieve==2.8
|
||||
svgwrite==1.4.3
|
||||
tqdm==4.67.1
|
||||
typing-inspection==0.4.0
|
||||
typing_extensions==4.13.1
|
||||
typer==0.20.0
|
||||
typing_extensions==4.15.0
|
||||
urllib3==2.5.0
|
||||
wavedrom==2.0.3.post3
|
||||
wcwidth==0.2.14
|
||||
yarg==0.1.10
|
||||
|
||||
Reference in New Issue
Block a user