mirror of
https://github.com/SevaSk/ecoute.git
synced 2024-12-19 20:57:53 +00:00
GTP response error check
This commit is contained in:
parent
9bac8bf41b
commit
02d1f12c76
@ -6,11 +6,15 @@ import time
|
||||
openai.api_key = OPENAI_API_KEY
|
||||
|
||||
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
|
||||
)
|
||||
try:
|
||||
response = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo-0301",
|
||||
messages=[{"role": "system", "content": create_prompt(transcript)}],
|
||||
temperature = 0.0
|
||||
)
|
||||
except openai.OpenAIError:
|
||||
print("An error occurred while calling OpenAI ChatCompletion.")
|
||||
return ''
|
||||
full_response = response.choices[0].message.content
|
||||
try:
|
||||
return full_response.split('[')[1].split(']')[0]
|
||||
|
Loading…
Reference in New Issue
Block a user