Skip to content

chndranndr/ImaginChat

Repository files navigation

ImaginChat

A powerful, fully client-side AI roleplay chat application with multi-LLM provider support and cross-platform capabilities.

100% client-side β€” ImaginChat runs entirely in your browser. There is no backend server. All data (characters, chats, personas, API keys, lorebooks, settings) is stored in your browser's localStorage. Your API keys never leave your device β€” they are sent directly from your browser to the LLM provider.

Features

πŸ€– Multi-LLM Provider Support

  • Gemini (Google) - Default provider with advanced features
  • Deepseek - Cost-effective alternative with strong performance
  • Grok (xAI) - X's AI model with unique capabilities
  • Profile Management - Save multiple API keys and switch providers seamlessly
  • Custom Models - Specify any model name for each provider

πŸ’¬ Advanced Chat Features

  • Direct Roleplay - One-on-one conversations with AI characters
  • Group Chats - Multiple characters in the same conversation
  • Story Mode - AI-driven narrative generation
  • Memory System - Automatic context extraction every 5 messages
  • Streaming Responses - Real-time message generation
  • Markdown Support - Rich text formatting in messages

🎭 Character System

  • AI Character Generation - Gemini-powered profile creation
  • Custom Characters - Manually create detailed character profiles
  • Character Settings - Per-character AI parameters
  • Multi-language Support - Characters can speak different languages
  • Avatar Support - Custom images for characters

πŸ‘€ Persona Management

  • Create Multiple Personas - Play as different characters across sessions
  • View & Edit Personas - Full description view and inline editing
  • Per-Session Persona - Each chat session remembers its persona

πŸ“œ Lorebook (World Info)

  • Keyword-Triggered Lore - Inject world info when keywords appear in chat
  • Logical Operators - AND, OR, NOT logic for keyword matching
  • Recursive Scanning - Lore entries can trigger other entries (2 levels deep)
  • Import/Export - SillyTavern V2 compatible format
  • Always Active Entries - Inject lore regardless of keywords

🧩 Prompt System

  • Structured Templates - Modular JSON-based prompt templates for roleplay and story modes
  • Customizable Templates - Edit system prompts via the built-in Template Editor
  • Prompt Library - Reusable prompt scripts with {{scriptName}} injection
  • Global & Per-Character Overrides - Layer system prompts at different levels

πŸ“± Cross-Platform

  • Fully Client-Side - No backend server, everything runs in the browser
  • Web App - Run in any modern browser
  • Android APK - Build native Android apps with Capacitor
  • Local Storage - All data persists locally (characters, chats, settings, profiles)

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • (Optional) Android Studio for APK builds

Installation

# Clone the repository git clone <repository-url> cd ImaginChat # Install dependencies npm install # Run development server npm run dev

Visit http://localhost:3000 to use the app.

Setting Up LLM Providers

  1. Click the Settings icon (βš™οΈ) in the navigation bar
  2. Scroll to LLM Profiles section
  3. Click Add Profile to create a new provider profile:
    • Profile Name: e.g., "My Deepseek"
    • Provider: Select Gemini, Deepseek, or Grok
    • API Key: Your API key from the provider
    • Model Name: e.g., gemini-2.0-flash, deepseek-chat, grok-2
  4. Switch between profiles by clicking on them

Getting API Keys

Building for Android

Build APK

# Build web assets npm run build # Sync to Android npx cap sync android # Open in Android Studio npx cap open android

In Android Studio:

  1. Build β†’ Build Bundle(s) / APK(s) β†’ Build APK(s)
  2. Find APK in android/app/build/outputs/apk/debug/

Quick Build Script

npm run android

Guides

Project Structure

ImaginChat/ β”œβ”€β”€ services/ β”‚ β”œβ”€β”€ llm/ β”‚ β”‚ β”œβ”€β”€ types.ts # LLM provider interfaces β”‚ β”‚ β”œβ”€β”€ geminiProvider.ts # Gemini implementation β”‚ β”‚ β”œβ”€β”€ deepseekProvider.ts # Deepseek implementation β”‚ β”‚ β”œβ”€β”€ grokProvider.ts # Grok implementation β”‚ β”‚ └── llmService.ts # Provider factory β”‚ β”œβ”€β”€ prompts/ β”‚ β”‚ β”œβ”€β”€ systemPromptBuilder.ts # Shared prompt assembly β”‚ β”‚ β”œβ”€β”€ promptTemplates.ts # Template loading & interpolation β”‚ β”‚ └── templates/ # JSON prompt templates β”‚ β”‚ β”œβ”€β”€ roleplay.json β”‚ β”‚ β”œβ”€β”€ story.json β”‚ β”‚ └── common.json β”‚ └── lorebook/ β”‚ β”œβ”€β”€ lorebookEngine.ts # Keyword scanning & RAG logic β”‚ └── lorebookService.ts # CRUD & import/export β”œβ”€β”€ components/ β”‚ β”œβ”€β”€ ChatInterface.tsx # Main chat UI β”‚ β”œβ”€β”€ CharacterForm.tsx # Character creation/editing β”‚ β”œβ”€β”€ PersonaManager.tsx # Persona view, edit, select β”‚ β”œβ”€β”€ LorebookManager.tsx # Lorebook CRUD UI β”‚ β”œβ”€β”€ PromptTemplateEditor.tsx # System template editor β”‚ β”œβ”€β”€ PromptLibrary.tsx # Reusable prompt scripts β”‚ └── ... β”œβ”€β”€ docs/ β”‚ β”œβ”€β”€ guide-system-prompts.md # System prompt guide β”‚ └── guide-lorebooks.md # Lorebook guide β”œβ”€β”€ App.tsx # Main app with LLM profile UI β”œβ”€β”€ types.ts # TypeScript types β”œβ”€β”€ capacitor.config.ts # Capacitor configuration └── android/ # Generated Android project 

Configuration

Vite Config

  • base: './' - Required for Capacitor
  • Environment variables for API keys

Capacitor Config

  • App ID: com.imaginai.chat
  • App Name: ImaginChat
  • Web Dir: dist

Development

# Development server npm run dev # Build for production npm run build # Preview production build npm run preview # Sync Capacitor npm run cap:sync # Open Android Studio npm run cap:open

Data Storage

ImaginChat is fully client-side β€” there is no backend. All data is stored in browser localStorage:

  • Characters and personas
  • Chat sessions and messages
  • LLM profiles (including API keys)
  • Lorebooks and prompt templates
  • Global settings and prompt scripts

Note: API keys are stored locally in your browser and sent directly to the LLM provider. They never pass through any intermediary server. This is acceptable for personal use but not recommended for production apps with sensitive credentials.

License

MIT

Contributing

Contributions welcome! Please open an issue or PR.

About

rp chatbot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors