mirror of
https://github.com/SevaSk/ecoute.git
synced 2024-12-24 14:56:39 +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
|
openai.api_key = OPENAI_API_KEY
|
||||||
|
|
||||||
def generate_response_from_transcript(transcript):
|
def generate_response_from_transcript(transcript):
|
||||||
|
try:
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
model="gpt-3.5-turbo-0301",
|
model="gpt-3.5-turbo-0301",
|
||||||
messages=[{"role": "system", "content": create_prompt(transcript)}],
|
messages=[{"role": "system", "content": create_prompt(transcript)}],
|
||||||
temperature = 0.0
|
temperature = 0.0
|
||||||
)
|
)
|
||||||
|
except openai.OpenAIError:
|
||||||
|
print("An error occurred while calling OpenAI ChatCompletion.")
|
||||||
|
return ''
|
||||||
full_response = response.choices[0].message.content
|
full_response = response.choices[0].message.content
|
||||||
try:
|
try:
|
||||||
return full_response.split('[')[1].split(']')[0]
|
return full_response.split('[')[1].split(']')[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user