A step-by-step educational project for learning and experimenting with AI agent design patterns using OpenAI's APIs. This repository demonstrates the progressive development of AI agents, starting with simple text completions and gradually integrating images, audio, and different interaction models - all with the fun use case of creating mystical and humorous oracle experiences.
This project serves as a practical guide for:
- Following a progression from simple to complex AI agent design
- Starting with basic text completion and gradually adding images and audio
- Learning to build fun, creative applications (oracles, fortune tellers, etc.)
- Exploring different interaction patterns (CLI, web interface, voice)
- Building multimodal AI applications that combine text, image, and audio
- Understanding how to chain AI capabilities together into cohesive experiences
- Oracle Text (
1OracleText.py): The simplest starting point - provides text-based oracle readings using GPT - Evil Mother-In-Law (
3EvilMotherInLaw.py): A character-based conversational oracle with personality
- Image Oracle (
2ImageOracle.py): Introduces basic image generation based on textual descriptions - Image Output Oracle (
4ImageOutputOracle.py): Enhances the image generation with better output handling - Sacred Symbol Oracle (
5imageoutput-oracle.py): Generates personalized mystical symbols based on user names
- Image Telephone Game (
6image-telephone.py): Implements a creative chain where images and descriptions evolve in sequence - Past Lives Oracle (
7pastlives.py,7pastlivespeechtospeech.py): Creates stories and images about users' past lives with added audio
- Streamlit Chat (
8streamlit_chat.py): A web-based chat interface for conversational AI - Streamlit Oracle (
9streamlit_oracle.py): A polished web application for the Sacred Symbol Oracle
- Progressive API Integration: Starting with basic GPT completions and adding DALL-E and TTS APIs
- Prompt Engineering: Crafting effective and entertaining prompts for oracle predictions
- Multi-modal Systems: Learning to combine text, image, and audio generation
- User Interface Design: Evolving from CLI to web-based interfaces with Streamlit
- Agent Chaining: Building more complex applications by connecting multiple AI capabilities
- Error Handling: Graceful management of API limits and failures
- File Management: Organizing and saving generated oracle content
- Download Python 3.8 or newer from python.org
- During installation, check "Add Python to PATH"
- Verify installation by opening a command prompt/terminal and typing:
python --version
- Download and install VS Code from code.visualstudio.com
- Install recommended extensions:
- Python extension (by Microsoft)
- Jupyter (for notebook files)
- GitLens (for better Git integration)
- Download and install Git from git-scm.com
- Configure Git with your name and email:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
- The
.gitignorefile tells Git which files to ignore when tracking changes - This is crucial for:
- Security: Preventing sensitive data (API keys, credentials) from being shared
- Cleanliness: Avoiding adding generated files, cache, or logs to your repository
- Performance: Keeping your repository size small and clone/pull operations fast
- Our project already includes a
.gitignorefile configured for AI development - You should review it to understand which files are excluded from version control
- Never edit the
.gitignoreto track sensitive files like.envor API keys!
-
Clone this repository
# Open a terminal/command prompt git clone https://github.com/yourusername/slimeGPT.git cd slimeGPT
Alternatively, if you don't use Git yet:
- Download the ZIP from the GitHub repository
- Extract it to a folder
- Open a terminal/command prompt and navigate to that folder
-
Open the project in VS Code
code . -
Create and activate a virtual environment
# Create the virtual environment python -m venv openai-env # Activate it on Windows openai-env\Scripts\activate # Activate it on macOS/Linux source openai-env/bin/activate
You'll know it's activated when you see
(openai-env)at the beginning of your terminal prompt. -
Install dependencies
pip install -r requirements.txt
-
Set up your API key using one of these methods:
Method A: Using a .env file (recommended for development)
Create a file named
.envin the project root:OPENAI_API_KEY=your_api_key_hereMethod B: Using Streamlit secrets (for Streamlit apps)
Create a folder
.streamlitand a filesecrets.tomlinside it:[openai] OPENAI_API_KEY = "your_api_key_here"
Method C: Set as environment variable (system-wide)
On Windows (Command Prompt):
setx OPENAI_API_KEY "your_api_key_here"On macOS/Linux:
echo 'export OPENAI_API_KEY="your_api_key_here"' >> ~/.bashrc source ~/.bashrc
Each Python file in the project is a standalone application that demonstrates a progressive step in AI agent design:
# Start with basic text oracle
python 1OracleText.py
# Move to image generation
python 2ImageOracle.py
python 5imageoutput-oracle.py
# Try the more complex multimodal applications
python 6image-telephone.py
python 7pastlives.py
# Explore the web interfaces last
streamlit run 8streamlit_chat.py
streamlit run 9streamlit_oracle.pyFor the best learning experience, follow the numbered sequence of examples to see how capabilities are progressively added.
Here's the typical workflow you'll follow each time you work on this project:
# Navigate to your project directory
cd path/to/slimeGPT
# Open VS Code in this directory
code .- In VS Code, press
Ctrl+`(backtick) to open a new terminal - Or go to Terminal β New Terminal in the menu
# On Windows
openai-env\Scripts\activate
# On macOS/Linux
source openai-env/bin/activateYou'll see (openai-env) appear at the beginning of your terminal prompt when it's activated.
To run a basic Python script:
python 1OracleText.pyTo run a Streamlit app:
streamlit run 9streamlit_oracle.py- For regular Python scripts, the program will stop when finished
- For Streamlit apps:
- The app runs in your browser at http://localhost:8501 by default
- To stop the server, go back to your terminal and press
Ctrl+C
When you're done working:
deactivateThe (openai-env) prefix will disappear from your terminal prompt.
This project not only showcases AI agents as oracles but can also be developed with the help of AI programming assistants. Here's how to leverage AI agents for your development workflow:
GitHub Copilot is an AI pair programmer that can help you write code faster and with fewer errors. Here's how to set it up:
-
Sign up for GitHub Copilot:
- Visit GitHub Copilot and sign up for the service
- GitHub Copilot is free for verified students, teachers, and maintainers of popular open-source projects
- For others, a subscription is required
-
Install the GitHub Copilot extension in VS Code:
- Open VS Code
- Go to the Extensions view by clicking the Extensions icon in the Activity Bar or pressing
Ctrl+Shift+X - Search for "GitHub Copilot"
- Click Install
-
Authenticate GitHub Copilot:
- After installation, you'll be prompted to sign in to GitHub
- Follow the authentication steps to connect your GitHub account
- Once authenticated, Copilot will be activated in your editor
Copilot can significantly accelerate your development of AI agents in this project:
-
Code Completion: As you type, Copilot will suggest code completions based on context:
- OpenAI API calls
- Prompt templates
- Error handling patterns
- UI components for Streamlit
-
Learning from Examples: Ask Copilot to explain the existing code:
# Asking Copilot: Explain how this code generates oracle predictions -
Extending Functionality: When adding new features to an agent:
# Copilot, help me add audio output to this oracle -
Debugging: When you encounter errors in your agents:
# Copilot, debug this OpenAI API error
When using AI tools like GitHub Copilot for developing AI agents:
-
Review All Suggestions: Always review AI-generated code for:
- Correct API usage (parameters, endpoints)
- Security best practices (proper key handling)
- Performance considerations
- Alignment with your project's style
-
Use Comments for Guidance: Write descriptive comments to guide the AI:
# Generate a function that takes a user name and returns a personalized oracle reading # using GPT-4 with appropriate error handling
-
Iterative Refinement: Use AI tools to:
- Generate a basic implementation
- Review and edit the code
- Ask for specific improvements
- Refine until the code meets your requirements
-
Learn, Don't Just Copy: Use AI-generated code as a learning opportunity:
- Understand why certain approaches were suggested
- Research unfamiliar patterns or functions
- Refactor code to improve your understanding
By combining your creativity with AI programming assistants, you can build more sophisticated and reliable AI agents while accelerating your learning process.
If you're using this project to learn about AI agent design, here are some concepts to explore:
- Prompt Engineering for Creativity: Study how the prompts in each oracle create entertaining and mystical outputs
- Progressive Complexity: Notice how each numbered example adds new capabilities to the previous one
- Chain-of-Thought: Look at how the telephone game chains multiple AI capabilities for creative results
- Multimodal Integration: Examine how text, image, and audio work together in the past lives oracle
- UI/UX for Oracle Applications: Compare the CLI vs. Streamlit interfaces for mystical experiences
- Character Development: Learn how to create AI agents with distinct personalities like the Evil Mother-In-Law
- Never commit your
.envfile or expose your API key - The application uses secure handling for API keys
- API keys are stored in environment variables for security
- Empty folders in the repository are maintained with
.gitkeepfiles- These are just empty placeholder files that allow git to track otherwise empty folders
- Git doesn't track empty directories by default, but our project needs these folders to save generated content
- You'll find these in
oracle_symbols/,output_audio/, andtelephone_game/folders
- The
.gitignorefile is configured to:- Exclude your API keys and environment files for security
- Ignore generated content (images, audio) to keep the repository size small
- Exclude Python cache files and virtual environment directories
MIT License