Conversion_Kitchen_Code/kitchen_counter/scriptAudit/gtp.py

36 lines
838 B
Python
Raw Normal View History

2024-04-27 09:33:09 +00:00
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