Skip to content

wh0isdsmith/narr_ai_tive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Narr.AI.tive Banner

Narr.AI.tive ๐Ÿค–๐Ÿ“š

Visual Studio Google Gemini Hugging Face GitHub Copilot Python Hatch project License: MIT

๐Ÿš€ A next-generation AI story generator powered by Google's Gemini model

๐Ÿ“– Overview

Narr_ai_tive is an advanced AI-powered story generator that leverages Google's Gemini model to create rich, engaging narratives. Here is a detailed overview of its features and functionalities:

๐Ÿ“š Table of Contents

โœจ Features

๐Ÿง  Advanced Story Generation

  • ๐Ÿค– Gemini-Powered Generation - Leverage Google's cutting-edge language model
  • ๐ŸŽญ Multiple Story Styles - From dark fantasy to sci-fi and beyond
  • ๐Ÿ‘ฅ Character Integration - Deep character development and consistency
  • ๐ŸŒ World Building - Rich world details and environment descriptions
  • ๐Ÿ“š Plot Management - Smart context tracking and story progression

๐Ÿ” Smart Content Management

  • ๐Ÿงฎ Semantic Search - Find relevant context using advanced embeddings
  • ๐Ÿ“ Auto-Chunking - Intelligent content organization
  • ๐Ÿ’พ Caching System - Efficient generation with smart caching
  • ๐ŸŽญ Character Profiles - Detailed character management
  • ๐ŸŒŸ World Details - Comprehensive world-building system

๐Ÿ“Š Quality Metrics

  • ๐Ÿ“ˆ Multi-Metric Evaluation - ROUGE, BLEU, semantic similarity
  • ๐Ÿ“š Lexical Analysis - Vocabulary richness and diversity checks
  • ๐Ÿ”„ Iterative Improvement - Quality-based regeneration
  • โš–๏ธ Configurable Thresholds - Customizable quality standards

๐Ÿ–ฅ๏ธ Multiple Interfaces

  • ๐ŸŽจ Rich TUI - Beautiful terminal interface with progress tracking
  • โŒจ๏ธ CLI Support - Command-line automation capabilities
  • ๐Ÿ“ฑ Interactive Mode - Dynamic story development
  • ๐Ÿ“ Export Options - Multiple output formats (TXT, MD, HTML)

๐Ÿš€ Quick Start

Prerequisites

Before installing Narr_ai_tive, ensure you have:

Required Software

  • Python 3.8+
  • Hatchling
  • Google API key (Gemini access)

Required Data Setup

  • Document embeddings in data/embeddings.json
    • See Embeddings Setup Guide
    • Must be generated before running the application
    • Uses sentence-transformers format
    • Required for semantic search functionality

Required Files Structure

data/
โ”œโ”€โ”€ embeddings.json     # Your document embeddings
โ”œโ”€โ”€ character_profiles.json
โ””โ”€โ”€ world_details.json

API Keys

  • Google Gemini API key
  • Store in secrets.yaml
  • Never commit this file to version control

Installation

# Clone repository
git clone https://github.com/yourusername/Narr_ai_tive.git
cd Narr_ai_tive

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
# OR
venv\Scripts\activate     # Windows

# Install dependencies
pip install -r requirements.txt

# Setup configuration
cp config.yaml.example config.yaml
# Add your API key to secrets.yaml

๐Ÿ’ป Usage

Interactive TUI

python -m app.main

CLI Generation

# Generate a single chapter
narr_ai_tive generate --query "A mystical journey begins" --style "epic fantasy"

# Generate with character focus
narr_ai_tive generate --input story.txt --character "Elena" --situation "dark forest"

Python API

from narr_ai_tive import StoryGenerator, load_config

# Initialize generator
config = load_config()
generator = StoryGenerator(config)

# Generate content
story = generator.generate_chapter(
    query="Ancient secrets revealed",
    style="mystery",
    character="Professor Blake"
)

๐ŸŽฏ Project Structure

๐Ÿ“ฆ Narr_ai_tive
 โ”ฃ ๐Ÿ“‚ app
 โ”ƒ โ”ฃ ๐Ÿ“œ chapter.py      # Chapter generation
 โ”ƒ โ”ฃ ๐Ÿ“œ character.py    # Character management
 โ”ƒ โ”ฃ ๐Ÿ“œ context.py      # Context handling
 โ”ƒ โ”ฃ ๐Ÿ“œ export.py       # Story export functionality
 โ”ƒ โ”ฃ ๐Ÿ“œ interactive.py  # Interactive story mode
 โ”ƒ โ”ฃ ๐Ÿ“œ main.py        # Application entry point
 โ”ƒ โ”ฃ ๐Ÿ“œ path_utils.py   # Path resolution utilities
 โ”ƒ โ”ฃ ๐Ÿ“œ plot.py         # Plot management
 โ”ƒ โ”ฃ ๐Ÿ“œ prompt.py       # Prompt engineering
 โ”ƒ โ”ฃ ๐Ÿ“œ semantic_search.py  # Content search
 โ”ƒ โ”ฃ ๐Ÿ“œ session.py      # Session management
 โ”ƒ โ”ฃ ๐Ÿ“œ setup_logging.py # Logging configuration
 โ”ƒ โ”ฃ ๐Ÿ“œ story.py        # Story generation core
 โ”ƒ โ”ฃ ๐Ÿ“œ text_processing.py # Text processing utilities
 โ”ƒ โ”ฃ ๐Ÿ“œ tui.py          # Terminal user interface
 โ”ƒ โ”ฃ ๐Ÿ“œ utils.py        # Utility functions
 โ”ƒ โ”— ๐Ÿ“œ world.py        # World-building management
 โ”ฃ ๐Ÿ“‚ data
 โ”ƒ โ”ฃ ๐Ÿ“œ character_profiles.json
 โ”ƒ โ”ฃ ๐Ÿ“œ embeddings.json
 โ”ƒ โ”— ๐Ÿ“œ world_details.json
 โ”ฃ ๐Ÿ“œ config.yaml       # Configuration
 โ”— ๐Ÿ“œ secrets.yaml      # API keys

๐Ÿ› ๏ธ Configuration

api:
  batch_size: 10
  rate_limit: 10
embedding:
  chunk_size: 5000
  model: models/embedding-001
generation:
  temperature: 0.7
  model: models/gemini-exp-1206

๐Ÿ“ License

MIT License - feel free to use in your own projects!

โญ Show Your Support

Give a โญ๏ธ if this project helped you!

๐Ÿ“… Roadmap

I. Enhanced User Interaction for World Details

  1. Location Selection

    • Implement hierarchical location prompts to allow users to select locations in a structured manner.
    • Provide detailed descriptions for each location to enhance user understanding and selection accuracy.
  2. Theme and Motif Selection

    • Introduce checkbox-style selection for themes and motifs to allow users to select multiple options easily.
    • Offer explanations for each theme and motif to help users make informed choices.
  3. Lore Element Management

    • Add a "Quick Add" feature for lore elements to streamline the addition of new lore.
    • Develop a dedicated lore menu for more complex edits and management of lore elements.
    • Ensure that changes to lore are saved and integrated seamlessly into the application.
  4. Integrating World Details into create_prompt()

    • Incorporate selected locations, themes, and motifs into the prompt generation process.
    • Emphasize the importance of these elements in the generated prompts.
    • Integrate contextual and explicit lore references to enrich the prompts.
  5. Example and Further Refinements

    • Provide a comprehensive example that demonstrates the integration of world details into the prompt generation process.
    • Identify areas for further refinement and improvement.

II. Deeper Character Profile Interaction

  1. Emotional State

    • Offer predefined emotion options and allow for free-form emotion input.
    • Introduce emotion intensity levels to capture the depth of the character's feelings.
    • Implement emotion processing to reflect changes in the character's emotional state.
  2. Immediate Goals

    • Prompt users to input the character's immediate goals.
    • Optionally categorize goals by type and relate them to long-term goals.
  3. Relationship Relevance

    • Allow users to select relevant relationships and include relationship details in the prompt.
  4. Relationship Dynamics in Focus

    • Enable selection of interaction partners and retrieval of relationship descriptions.
    • Prompt users to input the current state of relationships and incorporate these states into the prompt.
  5. **Integrating into create_prompt()

    • Seamlessly integrate character profile interactions into the prompt generation process.
  6. Further Considerations

    • Explore additional ways to enhance character profile interactions.

III. Enhancing Prompt and Story Structure

  1. Plot Point Integration

    • Allow users to select plot points with descriptions and set adherence levels.
    • Enable marking plot points as completed or modified and prepending plot points to the prompt.
  2. Customizable Chapter Tone and Mood

    • Introduce tone and mood selection with optional intensity levels.
    • Incorporate selected tone and mood into the prompt.
  3. Style Prompt Refinements

    • Provide a prompt for style refinements and integrate these refinements into the prompt.
  4. Multi-Part Chapter Generation

    • Offer an option for multi-part chapter generation with part-specific prompts.
    • Combine generated parts into a cohesive chapter.
  5. Example and Further Refinements

    • Provide an example that demonstrates the integration of plot points, tone, mood, and style refinements.
    • Identify areas for further refinement and improvement.

IV. Advanced Customization and Control

  1. Direct Prompt Editing

    • Introduce a "Show Prompt" option to display and edit the generated prompt.
    • Implement input validation to ensure the edited prompt is valid.
  2. Parameter Tuning Per Chapter

    • Allow users to adjust chapter generation settings and store chapter-specific parameters.
    • Pass these parameters to the generate_story() and generate_chapter() functions.
  3. Embedding/Context Selection

    • Display top chunks of context and allow users to select relevant chunks for embedding.
  4. Example and Further Refinements

    • Provide an example that demonstrates advanced customization and control.
    • Identify areas for further refinement and improvement.

V. Implementation Considerations

  1. TUI Design with rich

    • Use rich panels, layouts, tables, and progress bars to create a user-friendly TUI.
    • Implement Prompt.ask() with choices and Confirm.ask() for user inputs.
  2. Error Handling

    • Ensure robust input validation and exception handling.
    • Provide user-friendly error messages.
  3. Modularity

    • Develop focused functions with well-defined interfaces and reusable components.
    • Organize code into modules and packages for better maintainability.
  4. User Experience

    • Provide clear instructions, intuitive flow, and feedback mechanisms.
    • Offer help and documentation, and ensure accessibility.
  5. Example: Combining rich Techniques

    • Demonstrate the use of rich techniques in a comprehensive example.

Made with โค๏ธ using Google's Gemini

About

Transform your storytelling with AI-powered narrative generation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages