A fully local, AI-powered role-playing chat application that runs entirely on your machine. Create immersive stories with multiple characters, each powered by open-source AI models.
- Define detailed scenarios with rich descriptions
- Create unlimited characters with unique personalities
- Built-in Narrator to guide the story
- Upload character images (for main characters)
- Automatic Mode: AI decides which character responds next
- Manual Mode: You control who speaks
- Natural dialogue with emotional reactions and gestures
- Toggle to show/hide reaction descriptions
- Edit any message to change the story direction
- Uses Ollama with local LLM models (completely free!)
- No external APIs or cloud services required
- Characters maintain personality and context throughout
- Intelligent response generation based on character traits
- Save conversations as JSON files
- Load and continue previous stories
- Automatic summarization for long conversations
- Navigate backward/forward through message history
- What Happens Next: Guide the story direction
- Never Forget: Important facts that persist in memory
- Regenerate: Reroll the last AI response
- Message Navigation: Browse conversation history
- Python 3.8+ (tested with Python 3.13.9)
- Ollama (for local AI models)
- Modern web browser
Windows:
- Download from: https://ollama.com/download/windows
- Run the installer
- Ollama will start automatically
macOS:
brew install ollamaLinux:
curl -fsSL https://ollama.com/install.sh | shOpen a terminal and run:
ollama pull llama3.2:1bThis downloads a 1.3GB model. For better quality (but slower), you can use:
ollama pull llama3.2:3bNavigate to the project directory and run:
pip install -r requirements.txtWindows/macOS: Ollama should start automatically. If not:
ollama serveLinux:
ollama servepython main.pyYou should see:
๐ญ Starting AI-Powered Role-Playing App...
๐ Make sure Ollama is running: ollama serve
๐ Download model if needed: ollama pull llama3.2:1b
๐ Open in browser: http://localhost:8000
Navigate to: http://localhost:8000
- Click "New Story" in the header
- Fill in:
- Scenario Description: The world, setting, and initial situation
- Character 1: Name and detailed description (personality, background, motivations)
- Character 2: Name and detailed description
- Click "Create"
Automatic Mode (Default):
- Click "Generate AI Response"
- The AI will choose which character speaks and generate their response
Manual Mode:
- Toggle off "Auto Response"
- Select a character from the dropdown
- Either:
- Click "Generate AI Response" to let AI write as that character
- Type your own message and click "Send"
Right Panel - Scenario Section:
- What Happens Next: Tell the AI what should happen in the story
- Never Forget: Add important facts that should always be remembered
- Click "Update" after making changes
- Click "Add Character" to add more characters anytime
- Upload images for main characters using the file input in their card
- Click on character cards to quickly select them
- Edit: Click "Edit" on any message to change it
- Regenerate: Reroll the last AI response
- โฌ ๏ธ Back: Go to previous message state
- โก๏ธ Forward: Return to newer message state
- Save: Click "Save" to store your conversation as JSON
- Load: Click "Load" to browse and restore saved conversations
- Conversations are saved in the
saved_conversations/folder
Include:
- Personality traits: Brave, cautious, witty, serious
- Background: Noble knight, street urchin, wise scholar
- Motivations: Seeking revenge, protecting family, finding truth
- Speech patterns: Formal, slang, poetic, technical
- Quirks: Nervous habits, catchphrases, mannerisms
Name: Captain Elena Voss
Description: A battle-hardened starship captain in her 40s.
Personality: Cynical but fair, trusts her gut, protects her crew fiercely.
Speech: Direct and military-precise, uses naval terminology.
Motivations: Redemption for a past mission failure, ensuring crew safety.
Quirks: Drums fingers when thinking, quotes old Earth literature.
In main.py, locate the get_ai_response() function:
def get_ai_response(prompt: str, model: str = "llama3.2:1b") -> str:Change "llama3.2:1b" to any model you've downloaded with Ollama:
llama3.2:3b- Better quality, slowermistral:7b- High quality, needs more RAMphi3:mini- Faster, less accurate
In main.py, change:
MAX_MESSAGES_BEFORE_SUMMARY = 20Higher values = less frequent summaries but longer context.
python main.pyOr edit the last line in main.py:
uvicorn.run(app, host="0.0.0.0", port=8000) # Change 8000 to your portmodchat/
โโโ main.py # FastAPI backend
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ static/ # Frontend files
โ โโโ index.html # Main UI
โ โโโ app.js # Frontend logic
โโโ saved_conversations/ # Saved JSON files
โโโ character_images/ # Uploaded character images
- Make sure Ollama is running:
ollama serve - Check if Ollama is on port 11434 (default)
- Download the model:
ollama pull llama3.2:1b - Verify:
ollama list
- Use a smaller model:
llama3.2:1binstead of3b - Close other applications to free up RAM
- Check CPU usage - AI inference is CPU-intensive
- Change the port in
main.py(last line) - Or kill the process using port 8000:
- Windows:
netstat -ano | findstr :8000thentaskkill /PID <PID> /F - Linux/Mac:
lsof -ti:8000 | xargs kill
- Windows:
- Make sure
character_images/directory exists - Check file permissions
- Try smaller image files (< 5MB)
- Start Small: Begin with 2-3 characters before adding more
- Be Specific: Detailed character descriptions = better AI responses
- Guide the AI: Use "What Happens Next" to steer the story
- Edit Freely: Don't hesitate to edit AI responses to fit your vision
- Save Often: Save your conversations regularly
- Experiment: Try regenerating responses for different outcomes
- 100% Local: No data leaves your machine
- No Tracking: No analytics or external connections
- Your Stories: All saved conversations are yours
- Open Source: Review the code anytime
This is a learning project, but feel free to:
- Report bugs
- Suggest features
- Share your story ideas
- Improve the prompts
This project uses:
- FastAPI (MIT License)
- Ollama (MIT License)
- Pydantic (MIT License)
The application itself is provided as-is for educational and personal use.
Built with:
- FastAPI - Modern Python web framework
- Ollama - Local LLM runtime
- llama3.2 - Meta's open-source language model
Potential future features:
- Character portraits generation
- Voice synthesis for dialogue
- Branching storylines
- Collaborative multiplayer mode
- Export to different formats (PDF, ePub)
- Custom AI model fine-tuning
Enjoy creating your stories! ๐ญ๐โจ
For questions or issues, check the Troubleshooting section or review the code in main.py and static/app.js.