36 lines
838 B
Python
36 lines
838 B
Python
|
import openai # Set up the OpenAI API client
|
||
|
from MNF.settings import OPENAI_API_KEY
|
||
|
|
||
|
class ScriptGelerator:
|
||
|
|
||
|
engine = "text-davinci-003"
|
||
|
max_tokens = 1024
|
||
|
n = 1
|
||
|
stop = None
|
||
|
temperature = 0.5
|
||
|
|
||
|
class Prompts:
|
||
|
SCREENPLAY = "Convert this idea into a Screenplay."
|
||
|
STORY = "Convert this idea idea a Story."
|
||
|
PITCH = "Convert this idea idea a Pitch."
|
||
|
|
||
|
def __init__(self, prompt) -> None:
|
||
|
openai.api_key = OPENAI_API_KEY
|
||
|
self.completion_params = {
|
||
|
"engine" : self.engine,
|
||
|
"max_tokens" : self.max_tokens,
|
||
|
"n" : self.n,
|
||
|
"stop" : self.stop,
|
||
|
"temperature" : self.temperature,
|
||
|
}
|
||
|
self.prompt = prompt
|
||
|
|
||
|
|
||
|
def generate(self, idea : str) -> str:
|
||
|
self.completion = openai.Completion.create(
|
||
|
**self.completion_params,
|
||
|
prompt = self.prompt + idea
|
||
|
)
|
||
|
response = self.completion.choices[0].text
|
||
|
return response
|