mirror of
https://github.com/Paillat-dev/FABLE.git
synced 2026-01-02 01:06:20 +00:00
Initial commit
This commit is contained in:
22
generators/script.py
Normal file
22
generators/script.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
import json
|
||||
import asyncio
|
||||
import openai
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
async def generate_script(title, description):
|
||||
with open('prompts/script.txt') as f:
|
||||
prompt = f.read()
|
||||
f.close()
|
||||
prompt = prompt.replace("[title]", title)
|
||||
prompt = prompt.replace("[description]", description)
|
||||
response = await openai.ChatCompletion.acreate(
|
||||
model="gpt-4",
|
||||
messages=[
|
||||
{"role":"user","content":prompt}
|
||||
],
|
||||
)
|
||||
return response['choices'][0]['message']['content']
|
||||
Reference in New Issue
Block a user