Last active
November 21, 2023 01:59
-
-
Save itrobotics/4839a002eb514285a82453aa1815de57 to your computer and use it in GitHub Desktop.
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 | |
# Replace 'YOUR_API_KEY' with your actual API key from OpenAI | |
api_key = 'YOUR_API_KEY' | |
# Initialize the OpenAI API client | |
openai.api_key = api_key | |
# Specify the prompt for text generation | |
prompt = "Once upon a time," | |
# Generate text using the GPT-3 model | |
response = openai.Completion.create( | |
engine="text-davinci-002", # You can choose different engines based on your use case | |
prompt=prompt, | |
max_tokens=50, # Adjust the number of tokens in the generated text | |
) | |
# Extract the generated text from the response | |
generated_text = response.choices[0].text | |
# Print the generated text | |
print(generated_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment