Skip to content

Generates full mythological universes using Gemini, LlamaIndex, and Gradio, with RAG-based lore Q&A and world exploration. 4th place – MCP 1st Birthday Hackathon.

License

Notifications You must be signed in to change notification settings

HetanshWaghela/MythForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✧ MYTHFORGE ✧ - The Living Mythology Engine

An AI-powered mythology world generator that creates complete, interconnected mythological universes from a single seed concept using Gemini, LlamaIndex, and Gradio.

"From a whisper of an idea, entire pantheons are born."

🔮 Live Demo

Try MythForge: https://huggingface.co/spaces/MCP-1st-Birthday/mythforge

MCP Server (Blaxel): Available for AI agents to generate mythologies programmatically.

Enter a seed concept like "A civilization that worships volcanoes as living gods" and watch an entire mythology come to life.

🚀 Technologies Used

Category Technology
LLM Google Gemini 2.0 Flash for mythology generation and Oracle Q&A
RAG Framework LlamaIndex for knowledge graph indexing and semantic search
Embeddings HuggingFace sentence-transformers for local embeddings
UI Framework Gradio 6.0 for immersive, themed web interface
Text-to-Speech ElevenLabs for dramatic audio narration
MCP Integration Blaxel for deploying MythForge as an MCP Server
Data Models Pydantic 2.0 for robust entity validation
Visualization Plotly for interactive timelines and relationship graphs
Language Python 3.11+

📁 Project Structure

mythforge/
├── app.py                      # Main Gradio application entry point
├── requirements.txt            # Python dependencies
├── mythforge/
│   ├── __init__.py
│   ├── app.py                  # Multi-page Gradio app with 8 chambers
│   ├── core/
│   │   ├── config.py           # Environment & settings management
│   │   └── exceptions.py       # Custom exceptions
│   ├── models/
│   │   ├── entities.py         # Pydantic models (Deity, Creature, Myth, etc.)
│   │   └── mythology.py        # Main Mythology container model
│   ├── services/
│   │   ├── gemini_service.py   # Gemini API integration & generation
│   │   ├── llamaindex_service.py # RAG & knowledge graph management
│   │   └── elevenlabs_service.py # Audio narration service
│   ├── ui/
│   │   ├── theme.py            # Custom dark fantasy theme & CSS
│   │   └── pages/              # 8 unique page modules
│   │       ├── genesis.py      # Mythology creation chamber
│   │       ├── sanctum.py      # Dashboard overview
│   │       ├── codex.py        # Entity wiki browser
│   │       ├── oracle.py       # RAG-powered Q&A chat
│   │       ├── theater.py      # Audio narration player
│   │       ├── timeline.py     # Divine history visualization
│   │       ├── realms.py       # Interactive world map
│   │       └── language.py     # Constructed language generator
│   ├── prompts/
│   │   └── mythology_prompts.py # Structured generation prompts
│   └── blaxel/
│       ├── mcp_server.py       # MCP Server with 7 tools
│       ├── agent.py            # FastAPI HTTP agent
│       └── blaxel.toml         # Blaxel deployment config
└── data/
    ├── mythologies/            # Saved mythology JSON files
    └── sessions/               # User session data

✨ Key Features

🌌 Genesis Chamber - World Creation

  • Multi-phase generation: Cosmology → Pantheon → Creatures → Places → Myths → Prophecies
  • Streaming progress: Real-time status updates during 60-90 second generation
  • Coherent worldbuilding: All elements interconnected through relationships

🏛️ The Sanctum - Dashboard

  • Statistics overview: Entity counts, relationship graphs
  • Quick navigation: Jump to any entity or chamber
  • Mythology summary: Key themes and concepts at a glance

📖 The Codex - Entity Wiki

  • Filterable browser: Search by entity type (Deity, Creature, Place, Myth, etc.)
  • Relationship mapping: See connections between entities
  • Rich details: Descriptions, attributes, quotes, abilities

🔮 Oracle Chamber - RAG Q&A

  • Conversational interface: Ask anything about your mythology
  • Context-aware responses: Powered by LlamaIndex semantic search
  • Source attribution: See which entities informed each answer

🎭 Narrator's Theater - Audio

  • Dramatic narration: ElevenLabs text-to-speech with epic voices
  • Content selection: Narrate myths, prophecies, deity descriptions
  • Playback controls: Full audio player with download option

⏳ Timeline - Divine History

  • Visual chronology: Plotly-powered interactive timeline
  • Era organization: Creation, Golden Age, Wars, Prophecies
  • Event details: Click to explore each historical moment

🗺️ Realms - World Map

  • Interactive visualization: Explore the cosmic geography
  • Realm connections: See how different planes connect
  • Location details: Sacred places, temples, forbidden zones

🗣️ Language Forge - Conlang Generator

  • Complete languages: Phonology, grammar, vocabulary
  • Writing systems: Runic, hieroglyphic, cuneiform options
  • Sacred texts: Sample prayers and inscriptions
  • Audio pronunciation: Hear words spoken aloud

🤖 MCP Server Integration (Blaxel)

MythForge is deployed as an MCP Server on Blaxel, allowing any AI agent to create and query mythologies:

Available Tools

Tool Description
create_mythology Generate a complete mythology from a seed concept
query_lore Ask questions about an existing mythology (RAG)
list_mythologies List all available mythologies
get_entity Get details about a specific entity
generate_language_vocabulary Create a constructed language
expand_myth Expand a myth into a full narrative
get_mythology_summary Get comprehensive mythology overview

MCP Server Endpoint

https://run.blaxel.ai/hetansh-waghela/functions/mythforge-mcp/mcp

🚀 Quick Start

Prerequisites

  • Python 3.11+
  • Google Gemini API key
  • (Optional) ElevenLabs API key for audio

Installation

  1. Clone the repository
git clone https://github.com/HetanshWaghela/mcp-project-hackathon
cd mcp-project-hackathon
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r mythforge/requirements.txt
  1. Set environment variables
# Create .env file in mythforge/
cp mythforge/.env.example mythforge/.env
# Edit with your API keys
GEMINI_API_KEY="your-gemini-api-key"
ELEVENLABS_API_KEY="your-elevenlabs-api-key"  # Optional
  1. Launch the application
cd mythforge
python app.py
  1. Open in browser
http://localhost:7860

🗣️ Sample Seed Concepts

🌋 Elemental Mythologies

  • "A civilization that worships volcanoes as living gods who demand sacrifice"
  • "An underwater kingdom where dreams become physical reality"
  • "Star-worshippers who believe constellations are frozen gods"

🌑 Dark Fantasy

  • "A realm where shadows have consciousness and wage war against light"
  • "A world where death is just the beginning of true existence"
  • "Beings who feed on forgotten memories and lost hopes"

🌿 Nature-Based

  • "A forest where every tree contains the soul of an ancestor"
  • "Mountain spirits who carve the faces of heroes into stone"
  • "Wind deities who carry whispered secrets across continents"

🔮 Cosmic Horror

  • "Ancient beings sleeping beneath the ocean, dreaming reality into existence"
  • "A pantheon of gods who are themselves mere thoughts of something greater"
  • "The space between stars where exiled deities plot their return"

🧠 Context Engineering

MythForge employs sophisticated context engineering techniques to ensure coherent, interconnected mythology generation:

📋 Structured Schema Enforcement

Seed Concept → Pydantic Models → JSON Schema → Validated Output
  • Pydantic 2.0 Models: Every entity (Deity, Creature, Myth, etc.) has strict type validation
  • Nested Relationships: Entities reference each other by ID, creating a graph structure
  • Schema-Guided Generation: LLM outputs are parsed and validated against predefined schemas

🔄 Multi-Phase Contextual Generation

Phase 1: Cosmology    → Context A
Phase 2: Pantheon     → Context A + B  
Phase 3: Creatures    → Context A + B + C
Phase 4: Places       → Context A + B + C + D
Phase 5: Myths        → Full Context (references all entities)
Phase 6: Prophecies   → Full Context + Temporal awareness

Each generation phase receives accumulated context from previous phases, ensuring:

  • Deities reference realms from cosmology
  • Creatures inhabit places that exist
  • Myths involve characters already created
  • Prophecies reference established lore

🕸️ Knowledge Graph RAG

Entities + Relationships → LlamaIndex Graph → Semantic Embeddings → Contextual Retrieval
  • Graph Construction: Mythology converted to nodes (entities) and edges (relationships)
  • HuggingFace Embeddings: Local sentence-transformers for semantic search
  • Context-Aware Retrieval: Oracle queries retrieve relevant entities + their relationships

🎯 Prompt Engineering Patterns

Pattern Implementation Purpose
System Prompts Role-based instructions for Gemini Set mythology expert persona
Few-Shot Context Entity examples in prompts Guide output structure
Chain-of-Thought Multi-phase generation Build complexity progressively
Output Schemas Pydantic JSON schemas Ensure parseable responses
Context Windowing Phase-based accumulation Manage token limits

📊 Context Flow Diagram

Context Flow

🌍 Real-World Impact

MythForge addresses genuine needs across multiple creative and educational domains:

🎮 Game Development

  • Indie Game Studios: Generate complete lore systems for RPGs, MMOs, and adventure games in minutes instead of months
  • Procedural Content: Create unique mythology for each playthrough in roguelikes and procedural games
  • World Consistency: Ensure all game lore is internally consistent with relationship tracking

✍️ Writers & Authors

  • Fantasy Worldbuilding: Instant foundation for novel series, short stories, and screenplays
  • Writer's Block Solution: Generate seed mythologies to spark creative inspiration
  • Consistency Checking: Query the Oracle to verify lore details while writing

🎲 Tabletop RPG

  • Campaign Creation: Generate pantheons, creatures, and prophecies for D&D, Pathfinder campaigns
  • Session Prep: Create rich lore handouts with audio narration for immersive sessions
  • Custom Settings: Build unique campaign settings with interconnected history

📚 Education

  • Mythology Studies: Generate comparative mythology examples for classroom discussion
  • Creative Writing Classes: Teaching tool for worldbuilding techniques
  • Language Learning: Constructed languages demonstrate linguistic concepts

🎬 Media & Entertainment

  • Film/TV Writers' Rooms: Rapid mythology prototyping for fantasy productions
  • Podcast Creators: Generate lore for fiction podcasts with audio narration ready
  • Content Creators: Unique mythology content for YouTube, TikTok worldbuilding channels

🤖 AI Agent Integration

  • MCP Server: Any AI assistant can generate mythologies via tool calls
  • Creative AI Pipelines: Chain mythology generation with image/music generation
  • Interactive Storytelling: Power AI dungeon masters and narrative games

🔧 Configuration Options

Environment Variables

Variable Required Description
GEMINI_API_KEY Yes Google Gemini API key
ELEVENLABS_API_KEY No ElevenLabs TTS API key
DEBUG No Enable debug logging
APP_PORT No Server port (default: 7860)

Generation Parameters

Parameter Default Description
Deities 5-8 Number of gods/goddesses
Creatures 6-10 Mythological beasts
Places 5-8 Sacred locations
Myths 4-6 Origin stories and legends
Prophecies 3-5 Foretold events

🔮 Potential Enhancements

🎯 Advanced AI Capabilities

  • Image Generation: AI-generated artwork for deities and creatures
  • Music Composition: Procedural hymns and ceremonial music
  • Interactive Fiction: Choose-your-own-adventure myth exploration
  • Mythology Fusion: Combine multiple mythologies into hybrid worlds

🔧 Technical Improvements

  • Persistent Storage: Database backend for mythology archives
  • Collaboration: Multi-user mythology building
  • Export Formats: PDF compendiums, ePub books, wiki exports
  • Version History: Track mythology evolution over time

🌐 Integration & Scalability

  • API Access: RESTful API for third-party integrations
  • Game Engine Plugins: Unity/Unreal mythology import
  • Tabletop RPG Export: D&D/Pathfinder stat blocks
  • World Anvil Integration: Export to worldbuilding platforms

🤖 Advanced Agent Capabilities

  • Multi-mythology Queries: Cross-reference multiple mythologies
  • Mythology Comparison: Analyze similarities between generated worlds
  • Lore Consistency Checker: Validate internal mythology logic
  • Expansion Suggestions: AI-recommended lore additions

🙏 Acknowledgments

  • Google Gemini - Powering the mythology generation engine
  • LlamaIndex - RAG framework for semantic search and knowledge graphs
  • Gradio - Beautiful UI framework for the immersive interface
  • ElevenLabs - Dramatic voice narration
  • Blaxel - MCP Server deployment platform
  • Hugging Face - Spaces hosting

📝 License

This project is licensed under the MIT License.


✧ May your mythologies echo through eternity ✧

About

Generates full mythological universes using Gemini, LlamaIndex, and Gradio, with RAG-based lore Q&A and world exploration. 4th place – MCP 1st Birthday Hackathon.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages