Created
January 8, 2025 16:15
-
-
Save Benhawkins18/da35dea92263e1f6ab64d8859d8cffcb to your computer and use it in GitHub Desktop.
Pump My Bags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import openai | |
| # Set up OpenAI API key | |
| openai.api_key = "your-openai-api-key" | |
| def generate_variations(prompt, num_variations=5): | |
| """ | |
| Generates variations of a given prompt using GPT-4. | |
| """ | |
| variations = [] | |
| for _ in range(num_variations): | |
| response = openai.ChatCompletion.create( | |
| model="gpt-4", | |
| messages=[ | |
| {"role": "system", "content": "You are a creative assistant."}, | |
| {"role": "user", "content": f"Generate a variation of: {prompt}"} | |
| ], | |
| temperature=0.9, | |
| max_tokens=50 | |
| ) | |
| variations.append(response['choices'][0]['message']['content'].strip()) | |
| return variations | |
| # Example usage | |
| prompt = "Pump my bags" | |
| variations = generate_variations(prompt, num_variations=10) | |
| # Print the generated variations | |
| for i, variation in enumerate(variations, 1): | |
| print(f"{i}. {variation}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment