Run queries with multiple AI servers
Project description
MultiBrain
MultiBrain is a powerful web application that queries multiple AI models simultaneously, providing real-time streaming responses and intelligent summaries. Built with Svelte 5 and FastAPI, it offers a modern, responsive interface for comparing AI responses side-by-side.
๐ Features
- Multi-Model Querying: Query multiple AI providers simultaneously (OpenAI, Anthropic, Groq, Ollama, etc.)
- Real-Time Streaming: Watch responses stream in real-time from all configured models
- Intelligent Summaries: Automatic synthesis of all responses into a unified, fact-checked summary
- Bring Your Own Keys: Secure, client-side API key management with local encryption
- Modern UI: Beautiful, responsive interface built with Svelte and Tailwind CSS
- Keyboard Shortcuts: Efficient navigation with customizable keyboard shortcuts
- No Limits: Configure unlimited AI models with no artificial restrictions
๐ Requirements
- Python 3.8+
- Node.js 16+
- npm or yarn
- Svelte 5.0+ (included in dependencies)
๐ ๏ธ Installation
Backend Setup
- Clone the repository:
git clone https://spacecruft.org/deepcrayon/multibrain
cd multibrain
- Create a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the package:
pip install -U pip setuptools wheel
pip install -e .
Frontend Setup
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
๐ฆ Running the Application
Development Mode
- Start the backend API server:
multibrain-api
The API server will run on http://localhost:8000
- In a new terminal, start the frontend development server:
cd frontend
npm run dev
The frontend will run on http://localhost:5173
Production Mode
- Build the frontend:
cd frontend
npm run build
- Start the backend with static file serving:
multibrain-api --serve-static
Visit http://localhost:8000 to use the application.
๐ง Configuration
Adding LLM Providers
- Click the "Configure LLMs" button in the header
- Select a provider preset or choose "Custom"
- Enter your API credentials:
- Display Name: A friendly name for the LLM
- API URL: The OpenAI-compatible endpoint
- Model: The specific model to use
- API Key: Your provider's API key
Supported Providers
- OpenAI: GPT-4, GPT-3.5-turbo
- Anthropic: Claude 3 Opus, Sonnet, Haiku
- Groq: Mixtral, Llama 2
- Ollama: Local models (Llama 2, Mistral, CodeLlama)
- Custom: Any OpenAI-compatible endpoint
Setting a Summary LLM
The summary LLM analyzes all responses and provides a unified answer:
- Configure at least one LLM
- In the configuration modal, select your preferred model from the "Summary LLM" dropdown
- The summary will automatically generate after all responses complete
โจ๏ธ Keyboard Shortcuts
Ctrl+K: Open LLM configurationCtrl+/: Focus query inputCtrl+Enter: Submit queryShift+?: Show keyboard shortcutsEscape: Close modals
๐๏ธ Architecture
Frontend (Svelte 5 + Vite)
The frontend has been fully migrated to Svelte 5, leveraging the latest features:
- Runes API: Using
$state,$derived,$effectfor reactive state management - Props with
$props(): Modern component prop handling - Bindable Props: Two-way binding with
$bindable - Snippets: Reusable template fragments for better composition
frontend/
โโโ src/
โ โโโ components/ # Svelte 5 components with runes
โ โโโ stores/ # State management (.svelte.js files)
โ โโโ lib/ # Utilities and helpers
โ โโโ App.svelte # Main application
Key Svelte 5 Features Used:
- State Management: All stores use
.svelte.jsextension with runes - Component Props: Migrated from
export letto$props() - Reactive Effects: Using
$effectfor side effects instead of$: - Performance: Leveraging Svelte 5's improved reactivity system
Backend (FastAPI)
src/multibrain/
โโโ api/
โ โโโ routes/ # API endpoints
โ โ โโโ streaming.py # SSE streaming logic
โ โ โโโ router.py # Route definitions
โ โโโ main.py # FastAPI application
๐ Security
- Local Storage: API keys are encrypted using Web Crypto API
- No Backend Storage: Keys are never sent to or stored on the backend
- Secure Proxy: Backend proxies requests to avoid CORS issues
- HTTPS Ready: Full support for secure deployments
๐งช Development
Svelte 5 Migration
This project has been fully migrated to Svelte 5. Key changes include:
- All components use the new runes API (
$state,$derived,$effect) - Stores are now
.svelte.jsfiles with reactive primitives - Props use the
$props()rune for better type safety - Two-way binding with
$bindablefor form inputs - Improved performance with Svelte 5's optimized compiler
Running Tests
# Backend tests
pytest
# Frontend tests
cd frontend
npm test
Component Development
When creating new components, follow the Svelte 5 patterns:
// Use $props() for component props
let { value = $bindable(''), onsubmit } = $props();
// Use $state for reactive state
let count = $state(0);
// Use $derived for computed values
let doubled = $derived(count * 2);
// Use $effect for side effects
$effect(() => {
console.log('Count changed:', count);
});
Building for Production
# Build Python package
python -m build
# Build frontend
cd frontend
npm run build
๐ API Documentation
Once the backend is running, visit:
- Interactive API docs:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Key Endpoints
POST /api/query/stream: Stream responses from multiple LLMsPOST /api/llm/validate: Test LLM configurationPOST /api/llm/models: List available models
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Alternative licensing under Creative Commons CC BY-SA 4.0 International is also available.
๐ Acknowledgments
- Built with Svelte 5 and FastAPI
- UI components styled with Tailwind CSS
- Markdown rendering by Marked
- Migrated to Svelte 5 runes API for improved performance and developer experience
๐ Support
- Documentation: https://spacecruft.org/deepcrayon/multibrain
- Issues: https://spacecruft.org/deepcrayon/multibrain/issues
Copyright ยฉ 2025 Jeff Moe
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multibrain-0.5.2.tar.gz.
File metadata
- Download URL: multibrain-0.5.2.tar.gz
- Upload date:
- Size: 145.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4960191b0df13b9ccb0fe6ce0fd9f066e42b170f720524dce23e4f9f357d5fe
|
|
| MD5 |
80d5f5c3f6a962127cbe92c4665f2aa1
|
|
| BLAKE2b-256 |
22591990155683cd058df0dcb99074aaf06c050a1a8b66a3a6560d79dc9ed565
|
File details
Details for the file multibrain-0.5.2-py3-none-any.whl.
File metadata
- Download URL: multibrain-0.5.2-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3333e831bf182766d4b9dc8ae45088b462cc3b31f3f8de3872d681f168202cb9
|
|
| MD5 |
b0ed1ba6a223a85bfdf4d241487c54cd
|
|
| BLAKE2b-256 |
0a74012966f6c6f50cb97c661986716e7a79cd407bab4d32d98b858331f8d8fe
|