Fictionista / story_generator.py
teamnassim's picture
added model along with final app
b55a663
raw
history blame
504 Bytes
import openai
class StoryGenerator:
def __init__(self, api_key):
openai.api_key = api_key
self.completion_model = "text-davinci-002"
def generate_story(self, prompt):
prompt = f"Once upon a time, {prompt}"
response = openai.Completion.create(
engine=self.completion_model,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
return response.choices[0].text