ecoute/GPTResponder.py

17 lines
518 B
Python
Raw Normal View History

2023-05-08 02:10:48 +00:00
import openai
from keys import OPENAI_API_KEY
2023-05-09 21:07:51 +00:00
from prompts import create_prompt
2023-05-08 02:10:48 +00:00
openai.api_key = OPENAI_API_KEY
2023-05-09 21:07:51 +00:00
def generate_response_from_transcript(transcript):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo-0301",
messages=[{"role": "system", "content": create_prompt(transcript)}],
temperature = 0.0
)
full_response = response.choices[0].message.content
try:
return full_response.split('[')[1].split(']')[0]
except:
return ''