A production-ready Streamlit application that generates Python code using Together AI's language models.
- Multiple AI Models: Choose from Llama 3.1, CodeLlama, and Mixtral models
- Advanced Controls: Fine-tune temperature and token limits
- Example Prompts: 8 pre-built prompts for quick testing
- Code Download: One-click download of generated code
- Professional UI: Clean, responsive interface with syntax highlighting
- Session Management: Maintains state between interactions
- Together AI API Key - Get it here
- Python 3.8+ installed
- Git (for deployment)
-
Clone or download this repository
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variable
# Windows (PowerShell) $env:TOGETHER_API_KEY="your_api_key_here" # Windows (CMD) set TOGETHER_API_KEY=your_api_key_here # Linux/Mac export TOGETHER_API_KEY=your_api_key_here
-
Run the application
streamlit run app.py
-
Open in browser - Navigate to
http://localhost:8501
- Create a new GitHub repository
- Upload the following files:
app.pyrequirements.txtREADME.md.gitignore
- Go to share.streamlit.io
- Sign in with GitHub
- Click "New app"
- Configure:
- Repository: Your GitHub repository
- Branch:
main - Main file:
app.py
- Click "Advanced settings"
- In Secrets, add:
TOGETHER_API_KEY = "your_api_key_here"
- Click "Deploy!"
Your app will be live in 2-3 minutes! 🎉
- Select a Model - Choose from the sidebar (Llama, CodeLlama, or Mixtral)
- Adjust Settings (Optional) - Fine-tune temperature and max tokens
- Enter a Prompt - Describe the code you want to generate
- Generate Code - Click the generate button
- Download - Save the generated code to a
.pyfile
- "Write a function to reverse a string"
- "Create a class for a binary search tree with insert and search methods"
- "Write a script to read a CSV file and calculate statistics"
- "Create a decorator for timing function execution"
- "Write a function to validate email addresses using regex"
| Model | ID | Best For |
|---|---|---|
| Llama 3.1 8B | meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo |
Fast responses |
| Llama 3.1 70B | meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo |
Complex tasks |
| CodeLlama 34B | codellama/CodeLlama-34b-Instruct-hf |
Code-specialized |
| Mixtral 8x7B | mistralai/Mixtral-8x7B-Instruct-v0.1 |
Balanced performance |
- Temperature (0.0-1.0): Controls creativity
- Lower = More deterministic
- Higher = More creative
- Max Tokens (500-4000): Controls response length
Value App/
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── README.md # Documentation (this file)
├── .gitignore # Git ignore rules
└── Research/ # Documentation and reference materials
- ✅ API keys via environment variables
- ✅ No secrets in repository
- ✅ Streamlit secrets management
- ✅
.gitignoreconfigured
- Test basic code generation
- Try different models
- Adjust parameters
- Test example prompts
- Verify download functionality
See the Research/ folder for comprehensive test prompts across various categories:
- Basic functions
- Data structures
- Algorithms
- File operations
- Web development
- OOP concepts
"API key not found"
- Check environment variable is set correctly
- For Streamlit Cloud: Verify secrets are configured
- Ensure key name is exactly
TOGETHER_API_KEY
"Module not found"
- Run
pip install -r requirements.txt - Check Python version is 3.8+
App won't load
- Check console for error messages
- Verify all files are in the same directory
- Check internet connection (for API calls)
Code generation fails
- Verify API key is valid
- Check Together AI service status
- Try a simpler prompt first
This project is created for educational purposes as part of CAP 4767 Data Mining course.
Course: CAP 4767 - Data Mining
Module: 5
Topic: AI Code Generation with Together AI
- ✅ Streamlit application deployed
- ✅ Together AI integration
- ✅ Clean user interface
- ✅ API key management via secrets
- ✅ Complete documentation
- ✅ GitHub repository
- Built with Streamlit
- Powered by Together AI
- Models: Meta Llama, CodeLlama, Mixtral
Made with ❤️ for CAP 4767
Last Updated: October 2025