A Python Streamlit application that generates text using OpenAI's GPT models and images using DALL-E.
- Text Generation: Generate text using GPT-3.5 or GPT-4
- Image Generation: Create images using DALL-E
- Download Results: Save generated text and images
- User-Friendly Interface: Clean, intuitive design
- Error Handling: Robust error handling and user feedback
- Customizable: Adjust creativity levels and model parameters
pip install -r requirements.txtYou'll need an OpenAI API key. Get one from OpenAI's website.
Set your API key as an environment variable:
Windows:
set OPENAI_API_KEY=your-api-key-heremacOS/Linux:
export OPENAI_API_KEY=your-api-key-herestreamlit run ai_generator.pyThe app will open at: http://localhost:8501
- Select "Generate Text" from the dropdown
- Choose your preferred model (GPT-3.5 or GPT-4)
- Enter your prompt in the text area
- Click "Generate"
- Download the generated text if needed
- Select "Generate Image" from the dropdown
- Choose your preferred image size
- Enter a detailed description of the image you want
- Click "Generate"
- Download the generated image if needed
- Model Selection: Choose between GPT-3.5 (faster, cheaper) or GPT-4 (more powerful, expensive)
- Creativity Level: Adjust how creative the AI responses should be (0.0 to 1.0)
- Image Size: Choose from 256x256, 512x512, or 1024x1024 pixels
- Creativity Level: Adjust how creative the image generation should be
- Be specific and detailed in your prompts
- Ask for different writing styles (creative, formal, technical, etc.)
- Include context for better results
- Try different prompts for varied outputs
- Be descriptive about style and mood
- Mention art style (realistic, cartoon, oil painting, etc.)
- Include details about composition and lighting
- Specify colors and atmosphere
To add support for other AI models, modify the generate_text() function:
def generate_text(prompt, model="gpt-3.5-turbo"):
# Add your custom model logic here
passThe app uses custom CSS for styling. Modify the CSS in the st.markdown() section to change the appearance.
pythonwebsiteai/
├── ai_generator.py # Main application
├── requirements.txt # Python dependencies
├── README.md # This file
└── generated_images/ # Downloaded images (created automatically)
-
"OpenAI API key not found"
- Make sure you've set the
OPENAI_API_KEYenvironment variable - Restart your terminal after setting the variable
- Make sure you've set the
-
"Error generating text/image"
- Check your internet connection
- Verify your OpenAI API key is valid
- Ensure you have sufficient API credits
-
App won't start
- Make sure all dependencies are installed:
pip install -r requirements.txt - Check that Streamlit is installed:
pip install streamlit
- Make sure all dependencies are installed:
- OpenAI has rate limits on API calls
- If you hit limits, wait a moment and try again
- Consider upgrading your OpenAI plan for higher limits
- Never commit your API key to version control
- Use environment variables for sensitive data
- The app doesn't store your API key locally
- Add support for more AI models
- Implement conversation history
- Add batch processing capabilities
- Include more image generation options
- Add user authentication
- Implement usage analytics
Feel free to submit issues and enhancement requests!
This project is open source and available under the MIT License.
Happy Generating! 🎨✨