# Chain of Symbol Story Generator

## Overview

This repository contains a Python implementation of the Chain of Symbol approach in prompt engineering, specifically applied to generating a science fiction story. The Chain of Symbol method is an advanced technique for structuring prompts when working with large language models (LLMs) like GPT-3 or GPT-4, enabling more complex and organized interactions.

## Features

- Implements the Chain of Symbol approach for story generation
- Uses OpenAI's GPT-3.5-turbo model for text generation
- Generates images for each step of the story creation process
- Produces a final compiled story with all elements

## Requirements

- Python 3.x
- OpenAI API key
- Required Python libraries: `openai`, `Pillow`, `IPython`

## Installation

1. Clone this repository:

git clone https://github.com/shiv2398/Symbol/tree/main ``` 2. Install required packages:

pip install openai pillow ipython
  1. Set up your OpenAI API key as an environment variable:
    export OPENAI_API_KEY='your-api-key-here'
    

Usage

Run the main script:

python chain_of_symbol_story_generator.py

This will generate a science fiction story using the Chain of Symbol approach, with the following steps:

  1. Generate a basic premise (Ω)
  2. Develop the main character (Δ)
  3. Create a plot outline (Φ)
  4. Write the opening paragraph (Ψ)

The script will display the output for each step and save corresponding images. A final compiled story will also be generated and displayed.

Code Structure

  • story_chain: A dictionary defining the Chain of Symbol structure
  • generate_story_element(): Function to generate story elements using the OpenAI API
  • text_to_image(): Function to create image representations of the generated text

Output

The script generates:

  • Text output for each step of the story creation process
  • PNG images for each step (Ω.png, Δ.png, Φ.png, Ψ.png)
  • A final compiled story (final_story.png)

Customization

You can modify the story_chain dictionary to change the steps, instructions, or context for each symbol in the chain. This allows for flexible adaptation of the Chain of Symbol approach to different story generation tasks or other creative processes.