2023-05-15 10:11:04 +02:00
|
|
|
import os
|
|
|
|
|
|
2023-06-25 16:12:23 +02:00
|
|
|
from utils.openaicaller import openai
|
|
|
|
|
|
|
|
|
|
with open('prompts/script.txt') as f:
|
|
|
|
|
global_prompt = f.read()
|
|
|
|
|
f.close()
|
2023-05-15 10:11:04 +02:00
|
|
|
|
|
|
|
|
async def generate_script(title, description):
|
2023-06-25 16:12:23 +02:00
|
|
|
prompt = global_prompt
|
2023-05-15 10:11:04 +02:00
|
|
|
prompt = prompt.replace("[title]", title)
|
|
|
|
|
prompt = prompt.replace("[description]", description)
|
2023-06-25 16:12:23 +02:00
|
|
|
'''response = await openai.ChatCompletion.acreate(
|
2023-05-15 10:11:04 +02:00
|
|
|
model="gpt-4",
|
|
|
|
|
messages=[
|
|
|
|
|
{"role":"user","content":prompt}
|
|
|
|
|
],
|
2023-06-25 16:12:23 +02:00
|
|
|
)''' # Deprecated. Use openaicaller.py instead
|
|
|
|
|
response = await openai.generate_response(model="gpt-4", messages=[{'role':'user', 'content': prompt}])
|
|
|
|
|
return response['choices'][0]['message']['content'] # type: ignore
|