This is a Flask API that implements a choose your own adventure conversation using the OpenAI GPT-3.5 Turbo model. It allows you to create interactive story-like conversations where users can make choices and receive responses based on those choices.
Before running the application, make sure you have the following:
- Python 3.7 or higher installed
- OpenAI API key
.env
file containing the OpenAI API key (refer to.env.example
for the required format)
- Clone the repository:
git clone https://github.com/preginald/aiTools.git
cd aiTools.git
- Create and activate a virtual environment (optional but recommended):
python3 -m venv venv
source venv/bin/activate
- Install the required dependencies:
pip install -r requirements.txt
- Rename the
.env-example
file to.env
.
mv .env-example .env
- Open the
.env
file and replaceYOUR_OPENAI_API_KEY
with your actual OpenAI API key.
OPENAI_API_KEY=YOUR_OPENAI_API_KEY
- Start the Flask server:
python pystory.py
- By default, the API will be accessible at
http://localhost:5000
. You can test it using a REST client or integrate it into your own applications.
Starts or continues a choose your own adventure conversation.
Request Body:
The request body must be in JSON format and include a messages
array containing the conversation messages. Each message object should have a role
and content
.
Example:
{
"messages": [ { "role": "system", "content": "Tell me a choose your own adventure story..." }, { "role": "user", "content": "Option A" }, ... ]
}
Response:
The API will respond with a JSON object containing the generated message content.
Example:
{
"message": "The generated message content..."
}
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request.
This project is licensed under the MIT License.