# oAI A native macOS AI chat application with support for multiple providers and advanced features. ## Features ### Multi-Provider Support - **OpenAI** - GPT models with native API support - **Anthropic** - Claude models with OAuth integration - **OpenRouter** - Access to 100+ AI models - **Ollama** - Local model inference ### Core Capabilities - **Streaming Responses** - Real-time token streaming for faster interactions - **Conversation Management** - Save, load, and delete chat conversations - **File Attachments** - Support for text files, images, and PDFs - **Image Generation** - Create images with supported models - **Online Mode** - Web search integration for up-to-date information - **Session Statistics** - Track token usage and costs - **Model Context Protocol (MCP)** - Filesystem access for AI models with configurable permissions ### UI/UX - Native macOS interface with dark mode support - Markdown rendering with syntax highlighting - Command history navigation - Model selector with detailed information - Footer stats display (tokens, cost, response time) ## Installation 1. Clone this repository 2. Open `oAI.xcodeproj` in Xcode 3. Build and run (⌘R) ## Configuration ### API Keys Add your API keys in Settings (⌘,): - OpenAI API key - Anthropic API key (or use OAuth) - OpenRouter API key - Ollama base URL (default: http://localhost:11434) ### Settings - **Provider** - Select default AI provider - **Streaming** - Enable/disable response streaming - **Memory** - Control conversation context (on/off) - **Online Mode** - Enable web search integration - **Max Tokens** - Set maximum response length - **Temperature** - Control response randomness ## Slash Commands ### Model & Chat - `/help` - Show help and available commands - `/model` - Open model selector (⌘M) - `/clear` - Clear current conversation - `/retry` - Regenerate last response - `/info [model]` - Display model information ### Conversation Management - `/save ` - Save current conversation - `/load` or `/list` - List and load saved conversations - `/delete ` - Delete a saved conversation - `/export [filename]` - Export conversation ### Provider & Settings - `/provider [name]` - Switch or display current provider - `/config` or `/settings` - Open settings (⌘,) - `/stats` - View session statistics - `/credits` - Check API credits/balance ### Features - `/memory ` - Toggle conversation memory - `/online ` - Toggle online/web search mode - `/mcp ` - Manage MCP filesystem access ### MCP (Model Context Protocol) - `/mcp add ` - Grant AI access to a folder - `/mcp remove ` - Revoke folder access - `/mcp list` - Show allowed folders - `/mcp write ` - Enable/disable file write permissions - `/mcp status` - Display MCP configuration ## File Attachments Attach files to your messages using the syntax: `@/path/to/file` Example: ``` Can you review this code? @~/project/main.swift ``` Supported formats: - **Text files** - Any UTF-8 text file (.txt, .md, .swift, .py, etc.) - **Images** - PNG, JPG, WebP (for vision-capable models) - **PDFs** - Document analysis with vision models Limits: - Maximum file size: 10 MB - Text files truncated after 50 KB (head + tail shown) ## Keyboard Shortcuts - `⌘M` - Open model selector - `⌘,` - Open settings - `⌘N` - New conversation - `↑/↓` - Navigate command history ## Development ### Project Structure ``` oAI/ ├── Models/ # Data models (Message, Conversation, Settings) ├── Views/ # SwiftUI views │ ├── Main/ # Chat, header, footer, input │ └── Screens/ # Settings, stats, model selector ├── ViewModels/ # ChatViewModel ├── Providers/ # AI provider implementations ├── Services/ # Database, MCP, web search, settings └── Utilities/ # Extensions, logging, syntax highlighting ``` ### Key Components - **ChatViewModel** - Main state management and message handling - **ProviderRegistry** - Provider selection and initialization - **AIProvider Protocol** - Common interface for all AI providers - **MCPService** - Filesystem tool integration - **DatabaseService** - Conversation persistence - **WebSearchService** - Online search integration ## Requirements - macOS 14.0+ - Xcode 15.0+ - Swift 5.9+ ## License MIT License - See [LICENSE](LICENSE) for details. ## Author **Rune Olsen** https://blog.rune.pm ## Contributing 1. Fork the repository 2. Create a feature branch 3. Submit a pull request --- **⭐ Star this project if you find it useful!**