Added and fixed a whole bunch of things

This commit is contained in:
Paillat
2023-05-15 15:35:08 +02:00
parent 393600ad94
commit da257e7b39
9 changed files with 69 additions and 41 deletions

View File

@@ -5,18 +5,23 @@ from dotenv import load_dotenv
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
subject = os.getenv("SUBJECT")
with open('prompts/ideas.txt') as f:
prompt = f.read().replace('[subject]', subject)
prompt = f.read()
f.close()
async def generate_ideas(path):
with open(f'{path}/ideas.json', 'r') as f:
ideas = f.read()
ides_json = json.loads(ideas)
f.close()
prmpt = prompt.replace('[existing ideas]', ideas)
async def generate_ideas(path, subject):
prmpt = prompt.replace('[subject]', subject)
try:
with open(f'{path}/ideas.json', 'r') as f:
ideas = f.read()
ides_json = json.loads(ideas)
f.close()
except:
ides_json = []
ideas = "There are no existing ideas."
prmpt = prmpt.replace('[existing ideas]', ideas)
print(prmpt)
response = await openai.ChatCompletion.acreate(
model="gpt-3.5-turbo",
messages=[