Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GenAI.py #9

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions GenAI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Gen AI #8

// Before using this code created using python for story creating in GenAI you have to install the open ai.
// follow the below code and write it in the terminal to do that

// pip install openai

// Code

import openai

# Set your OpenAI API key
openai.api_key = 'your_openai_api_key_here'

# Define the prompt you want to use
prompt = "Write a short story about a brave astronaut exploring a new planet."

# Call the OpenAI API to generate text
response = openai.Completion.create(
engine="text-davinci-003", # Use a suitable GPT-3 model
prompt=prompt,
max_tokens=150, # Limit the number of tokens (words) in the response
temperature=0.7, # Adjust the creativity level (0 to 1)
n=1, # Number of completions to generate
stop=None # Optional stopping condition
)

# Print the generated story
generated_story = response.choices[0].text.strip()
print("Generated Story:\n", generated_story)