← all conversations

AI Generated Text Adventure

2025-02-286 turns7,850 charsgpt-4o
text-adventurejekyllollama

Summary

The user wants to create a text adventure game for their Jekyll blog using markdown links and AI-generated stories via Ollama.

Messages

write a computer program which is a text adventure game in the form of an addition to my Jekyll blog hosted on netlify completely in markdown and use links in the game to tell the story. The story will be about me and the AI will tell the story. I will give it images and it will use LLaVa to analyze the images so that a story can be created from all of the photos. So an initial llm call to analyze the image, which is then expanded on into a full generation. That generation will have the key aspects of the story taken out and analyzed for themes in order to craft the story to fit together with all of the photos. So the markdown will be outputted with one page per photo and there will be links and text and the use decides which way to go and the story keeps going. I want to just use all of the photos and then they will be analyzed each with a story then each story will be analyzed and then all of the stories will be meta analyzed and then each one will be rewritten with the extracted themes and elements created after all of the meta analysis has been analyzed and a coherent singular overarching story which tells of adventure and thrilling stories about art and artificial intelligence. --integrate the ideas from this paper to write this computer program. I want first a high level architecture as well as a series of prompts that can be given to cline to create the addition to an already existing jekyll blog
### High-Level Architecture for the Jekyll-Based AI-Generated Text Adventure Game This system will generate a **Markdown-based text adventure** for your Jekyll blog, where AI analyzes images, generates stories, extracts themes, and creates an interconnected narrative. --- #### **1. System Components** 1. **Image Processing and Analysis** - Use **LLaVA** (LLaMA with Vision) to extract meaningful details from each image. - Store results as structured JSON with descriptions, objects, and potential narrative elements. 2. **Story Generation Pipeline** - **Per-image story creation:** A local LLM expands on LLaVA's analysis to create a short story for each image. - **Theme extraction:** Another LLM pass extracts key themes, motifs, and commonalities across all generated stories. - **Meta-narrative synthesis:** A final LLM pass rewrites each story to ensure a unified, coherent adventure. 3. **Markdown Story Formatting** - Convert each story into a Markdown file. - Add **navigation links** (`[Go left](page2.md)`) to allow branching choices. - Embed images and AI-generated text. 4. **Jekyll Integration** - The Markdown files are stored in `_posts/` or a custom `_stories/` directory. - The site regenerates with each update, publishing the new adventure. --- #### **2. Prompts for the AI Pipeline** These prompts guide the **LLM and LLaVA** for each step. ##### **(A) Image Analysis (LLaVA)** > "Analyze this image and describe: > - Objects, people, setting, and mood. > - Potential narrative themes and conflicts. > - Any artistic or stylistic elements." ##### **(B) Initial Story Generation (LLM)** > "Using the extracted details, write a 300-word adventure scene. > - Include a protagonist (default: the user). > - Make the scene vivid and immersive. > - End with 2-3 choices for what happens next." ##### **(C) Meta-Analysis for Theme Extraction** > "Analyze the following short stories and identify: > - Recurring motifs, emotions, or settings. > - Common narrative structures. > - Overarching themes that unify them." ##### **(D) Final Story Unification** > "Rewrite each scene so that all fit together into a single thrilling adventure. > - Ensure a consistent protagonist and tone. > - Maintain user choice branches. > - Strengthen connections between scenes." ##### **(E) Markdown Formatting** > "Format the final story as Markdown with: > - A title (`# Page Title`) > - The image embedded (`![alt text](image.jpg)`) > - Navigation links (`[Next](page2.md)`)." --- Would you like an **automated script** to generate and format these Markdown files from a directory of images? 🚀
gpt-4o
yes
Here's a Python script that automates the process of: 1. **Analyzing images with LLaVA** (assuming you're running it locally). 2. **Generating an initial story** using a local LLM. 3. **Extracting themes** from all stories. 4. **Rewriting the stories** for consistency. 5. **Generating Markdown files** with embedded images and links for Jekyll. This script assumes: - You're using `Ollama` for both LLaVA and LLM calls. - Images are stored in `input_images/`. - The output Markdown files will go in `_stories/` for Jekyll. I'll generate the script now.
gpt-4o
This script will: 1. **Analyze each image** in `input_images/` using LLaVA. 2. **Generate a corresponding adventure scene**. 3. **Extract overarching themes** from all stories. 4. **Rewrite each story** to fit the larger narrative. 5. **Save each story as a Markdown file** in `_stories/`, linking them together. Would you like to add **metadata (e.g., timestamps, authorship) or custom styling** to the Markdown files?
gpt-4o
IMPROVE THIS PROGRAM: import os import json import random from pathlib import Path import ollama # Directories INPUT_DIR = "input_images" OUTPUT_DIR = "_stories" os.makedirs(OUTPUT_DIR, exist_ok=True) # Step 1: Analyze Images with LLaVA def analyze_image(image_path): prompt = "Analyze this image and describe objects, setting, mood, and possible narrative elements." response = ollama.chat(model='llava', messages=[{"role": "user", "content": prompt}], files=[image_path]) return response['message']['content'] # Step 2: Generate Initial Story def generate_story(image_analysis): prompt = f"Using this analysis, write a 300-word thrilling adventure scene.\n\n{image_analysis}" response = ollama.chat(model='mistral-small:24b-instruct-2501-q8_0', messages=[{"role": "user", "content": prompt}]) return response['message']['content'] # Step 3: Extract Themes def extract_themes(stories): prompt = "Analyze these stories for recurring motifs, emotions, and overarching themes.\n\n" + "\n\n".join(stories) response = ollama.chat(model='mistral-small:24b-instruct-2501-q8_0', messages=[{"role": "user", "content": prompt}]) return response['message']['content'] # Step 4: Rewrite Stories for Coherence def rewrite_story(original_story, themes): prompt = f"Rewrite this story to align with the overall themes.\n\nThemes: {themes}\n\nStory: {original_story}" response = ollama.chat(model='mistral-small:24b-instruct-2501-q8_0', messages=[{"role": "user", "content": prompt}]) return response['message']['content'] # Step 5: Generate Markdown Files def save_markdown(story, image_filename, filename, choices): md_content = f""" # {filename.replace(".md", "").replace("_", " ").title()} ![Story Image](../{INPUT_DIR}/{image_filename}) {story} {choices} """ with open(os.path.join(OUTPUT_DIR, filename), "w", encoding="utf-8") as f: f.write(md_content) # Process Images stories = {} for image_file in Path(INPUT_DIR).glob("*.jpg"): analysis = analyze_image(str(image_file)) story = generate_story(analysis) stories[image_file.name] = story # Extract Overall Themes theme_summary = extract_themes(list(stories.values())) # Rewrite Stories for Coherence rewritten_stories = {img: rewrite_story(story, theme_summary) for img, story in stories.items()} # Generate Markdown with Choices story_files = list(rewritten_stories.keys()) random.shuffle(story_files) for i, (img, story) in enumerate(rewritten_stories.items()): choices = "" if i < len(story_files) - 1: next_story = story_files[i + 1].replace(".jpg", ".md") choices = f"[Continue](./{next_story})" save_markdown(story, img, img.replace(".jpg", ".md"), choices) print("Text adventure game successfully generated in Markdown!")