To run the application, you need to have Python 3 and pip installed on your system. Once you have those, follow the steps below:
-
Clone the repository:
git clone https://github.com/AkshayGMys/StoryGenerationAI
-
Navigate to the project directory:
cd StoryGenerationAI
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate # on Linux/macOS venv\Scripts\activate # on Windows
-
Install the required packages:
pip install -r requirements.txt
-
Obtain an API key from OpenAI and save it in a file named
.env
in the project directory with the following content:OPENAI_API_KEY=your_api_key_here
-
Run the application:
python app.py
-
Open your web browser and navigate to http://localhost:5000 to use the application.
The application consists of two routes:
-
/: This is the home route where the user can enter a prompt and submit it. The application then generates a story based on the prompt and displays it on the same page.
-
/prompt: This route displays the prompt and the generated story. It also allows the user to enter a new prompt and submit it.
The application uses the OpenAI API to generate the stories. The prompt
global variable is used to store the current prompt, and the generated_answer
global variable is used to store the generated story.