Skip to content

vykhand/llm-fandom

Repository files navigation

Wiki Generator

Transform any content into beautiful AI-powered wikis

An intelligent wiki generator that transforms books, websites, and documents into comprehensive, searchable wiki sites with automatically extracted entities, relationships, and beautiful formatting.

Python 3.10+ uv License: MIT

✨ Features

Core Capabilities

  • πŸ“„ Multi-Format Support - PDFs, websites, plain text, and markdown
  • πŸ€– AI-Powered Extraction - Automatic entity and relationship extraction using LLMs
  • πŸ”„ Multi-Provider LLM - Support for Anthropic Claude and OpenAI with automatic fallback
  • 🎨 Beautiful Output - Fandom-style static sites using MkDocs Material theme
  • πŸ”— Smart Linking - Automatic cross-linking between related entities
  • πŸ’Ύ Local Database - SQLite storage for all extracted data
  • πŸ›‘οΈ Robust Architecture - Retry logic, error handling, and graceful fallback

Entity Types

The system extracts and generates wiki articles for:

  • πŸ‘€ Characters - People, protagonists, supporting roles
  • πŸ—ΊοΈ Locations - Cities, buildings, regions, landmarks
  • πŸ›οΈ Organizations - Groups, companies, factions, institutions
  • πŸ’‘ Concepts - Ideas, theories, systems, technologies
  • βš”οΈ Events - Major occurrences, battles, turning points
  • ⚑ Items - Significant objects, artifacts, weapons

πŸš€ Quick Start

Prerequisites

  • Python 3.10 or higher
  • uv (dependency management)
  • API key for Anthropic Claude or OpenAI

Installation

# Clone the repository (if from git)
cd wiki-generator

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies with uv
uv sync --extra dev

# Set up environment variables
cp .env.example .env
# Edit .env and add your API keys:
# ANTHROPIC_API_KEY=sk-ant-your-key-here
# or
# OPENAI_API_KEY=sk-your-key-here

Verify Setup

uv run wiki-generator check-config

Generate Your First Wiki

Try the included sample story:

uv run wiki-generator generate examples/sample_story.txt --output ./my-wiki --verbose

Then serve it locally:

uv run wiki-generator serve ./my-wiki

Open http://localhost:8000 to view your wiki!

πŸ“– Usage

Basic Commands

# Generate from a PDF
wiki-generator generate book.pdf --output ./book-wiki

# Generate from a website
wiki-generator generate https://example.com/article --output ./web-wiki

# Generate and serve immediately
wiki-generator generate source.txt --serve

# Use custom configuration
wiki-generator generate book.pdf --config custom-config.yaml

# Check configuration and API keys
wiki-generator check-config

Command Options

wiki-generator generate [SOURCE] [OPTIONS]

Arguments:
  SOURCE              Path to PDF, URL, or text file

Options:
  -o, --output DIR    Output directory (default: ./output/site)
  -c, --config FILE   Configuration file path
  -v, --verbose       Enable verbose logging
  -s, --serve         Serve wiki after generation
  --help              Show help message

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Source    β”‚  (PDF, Web, Text)
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Content Parser  β”‚  Extract text and metadata
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Entity Extractorβ”‚  AI-powered entity extraction
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Wiki Generator  β”‚  Create comprehensive articles
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Site Builder   β”‚  MkDocs static site generation
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
  Beautiful Wiki

Key Components

  • Content Parsers: Handle PDF, web, and text sources
  • LLM Orchestrator: Multi-provider support with automatic fallback
  • Entity Extractor: Identifies and structures entities using AI
  • Wiki Generator: Creates detailed, cross-linked articles
  • Site Builder: Generates beautiful, searchable static sites
  • Storage Layer: SQLite database for persistence

βš™οΈ Configuration

Default Configuration

The system uses config/default_config.yaml. Key settings:

llm:
  providers:
    - name: anthropic
      model: claude-3-5-sonnet-20241022
    - name: openai
      model: gpt-4-turbo-preview
  fallback_order:
    - anthropic
    - openai

extraction:
  chunk_size: 4000
  entity_types:
    - character
    - location
    - organization
    - concept
    - event
    - item

site:
  theme: material
  site_name: Generated Wiki

Custom Configuration

Create your own YAML file to override defaults:

# my-config.yaml
site:
  site_name: "My Fantasy World Wiki"
  site_description: "Complete guide to my story universe"

extraction:
  chunk_size: 6000
  min_confidence: 0.7

Use it with:

wiki-generator generate source.txt --config my-config.yaml

πŸ“Š Examples

Sample Output

From the included examples/sample_story.txt, the generator creates:

πŸ“ my-wiki/
β”œβ”€β”€ πŸ“„ index.html (home page with statistics)
β”œβ”€β”€ πŸ‘€ characters/
β”‚   β”œβ”€β”€ Queen Celestia.md
β”‚   β”œβ”€β”€ Commander Theron Blackwood.md
β”‚   β”œβ”€β”€ Elara Moonwhisper.md
β”‚   └── ...
β”œβ”€β”€ πŸ—ΊοΈ locations/
β”‚   β”œβ”€β”€ Kingdom of Elendril.md
β”‚   β”œβ”€β”€ Silverhaven.md
β”‚   β”œβ”€β”€ Whispering Woods.md
β”‚   └── ...
β”œβ”€β”€ πŸ›οΈ organizations/
β”‚   β”œβ”€β”€ Shadow Council.md
β”‚   β”œβ”€β”€ Royal Guard.md
β”‚   └── ...
└── ⚑ items/
    β”œβ”€β”€ Starlight Amulet.md
    β”œβ”€β”€ Shadowbane.md
    └── ...

Each article includes:

  • Comprehensive description
  • Related entities (automatically linked)
  • Type-specific sections
  • Metadata and tags
  • Cross-references

πŸ§ͺ Testing

Run Tests

# Run all tests
uv run pytest

# Run with verbose output
uv run pytest -v

# Run specific test file
uv run pytest tests/test_models.py

Test Coverage

Current test coverage:

  • βœ… Core data models
  • βœ… Configuration loading
  • ⏳ Integration tests (pending)
  • ⏳ Parser tests (pending)

πŸ“š Documentation

πŸ”§ Development

Project Structure

wiki-generator/
β”œβ”€β”€ src/wiki_generator/     # Main package
β”‚   β”œβ”€β”€ core/               # Models, config, pipeline
β”‚   β”œβ”€β”€ llm/                # LLM providers and orchestration
β”‚   β”œβ”€β”€ parsers/            # Content parsers
β”‚   β”œβ”€β”€ extraction/         # Entity extraction
β”‚   β”œβ”€β”€ generation/         # Wiki generation
β”‚   β”œβ”€β”€ site/               # Static site building
β”‚   └── storage/            # Database layer
β”œβ”€β”€ config/                 # Configuration files
β”‚   β”œβ”€β”€ default_config.yaml
β”‚   └── prompts/            # Jinja2 templates
β”œβ”€β”€ tests/                  # Unit tests
β”œβ”€β”€ examples/               # Sample content
└── docs/                   # Documentation

Contributing

Contributions are welcome! Areas for improvement:

  1. Image Pipeline - Implement automatic image acquisition
  2. Integration Tests - End-to-end testing
  3. Performance - Optimization for large books
  4. Local LLMs - Support for Ollama, llama.cpp
  5. UI Enhancements - Custom themes, visualizations

⚠️ Known Limitations

  1. Images: Automatic image acquisition not yet implemented (Phase 6)

    • Articles won't have images automatically
    • Can manually add images to markdown files
  2. Performance: Optimized for books up to ~200 pages

    • Larger books work but may take longer
    • Consider chunking very large content
  3. LLM Dependency: Requires API access to Claude or GPT

    • Local LLM support planned
    • API costs apply (typically $1-3 for a medium book)

πŸ“ˆ Performance

Typical processing times (with Claude Sonnet 4.5):

  • Short story (10 pages): 2-5 minutes
  • Medium book (100 pages): 15-30 minutes
  • Large book (200 pages): 45-90 minutes

Cost estimates:

  • Small: ~$0.10-0.30
  • Medium: ~$1-3
  • Large: ~$3-10

πŸ—ΊοΈ Roadmap

v0.2.0 (Planned)

  • Image extraction from PDFs
  • Web image search
  • AI image generation (DALL-E)
  • Integration tests
  • Performance optimization

v0.3.0 (Future)

  • Local LLM support (Ollama)
  • Multi-language wikis
  • Custom entity types
  • Relationship visualization
  • Incremental updates

v1.0.0 (Vision)

  • Web UI
  • Collaborative editing
  • Export to Notion/Obsidian
  • GitHub Pages auto-deploy
  • Docker deployment

πŸ™ Acknowledgments

Built with excellent open-source tools:

πŸ“„ License

MIT License - see LICENSE file for details

πŸ†˜ Support

  • πŸ“– Read GETTING_STARTED.md for detailed setup instructions
  • πŸ—οΈ See ARCHITECTURE.md for technical details
  • πŸ› Report issues on GitHub
  • πŸ’¬ Enable --verbose flag for debugging

Made with ❀️ using AI and Python

Transform your content into beautiful wikis today! πŸš€

About

No description, website, or topics provided.

Resources

License

Stars

11 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors