Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,13 +15,9 @@ def chat_hf(audio, custom_token):
|
|
15 |
try:
|
16 |
whisper_text = translate(audio)
|
17 |
|
18 |
-
# Conversation
|
19 |
prompt = user_name + ": " + user_input + "\n" + bot_name+ ": "
|
20 |
conversation += prompt # allows for context
|
21 |
-
|
22 |
-
#api = ChatGPT(session_token)
|
23 |
-
#resp = api.send_message(whisper_text)
|
24 |
-
|
25 |
# fetch the response from open AI api
|
26 |
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
|
27 |
response_str = response["choices"][0]["text"].replace("\n", "")
|
@@ -29,21 +25,22 @@ def chat_hf(audio, custom_token):
|
|
29 |
|
30 |
conversation += response_str + "\n"
|
31 |
|
32 |
-
|
33 |
-
#api.refresh_auth() # refresh the authorization token
|
34 |
-
#api.reset_conversation() # reset the conversation
|
35 |
-
gpt_response = response_str #resp['message']
|
36 |
|
37 |
except:
|
38 |
-
|
39 |
-
|
40 |
-
#
|
41 |
-
#
|
42 |
-
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
47 |
|
48 |
return whisper_text, gpt_response
|
49 |
|
|
|
15 |
try:
|
16 |
whisper_text = translate(audio)
|
17 |
|
18 |
+
# Conversation route
|
19 |
prompt = user_name + ": " + user_input + "\n" + bot_name+ ": "
|
20 |
conversation += prompt # allows for context
|
|
|
|
|
|
|
|
|
21 |
# fetch the response from open AI api
|
22 |
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
|
23 |
response_str = response["choices"][0]["text"].replace("\n", "")
|
|
|
25 |
|
26 |
conversation += response_str + "\n"
|
27 |
|
28 |
+
gpt_response = response_str
|
|
|
|
|
|
|
29 |
|
30 |
except:
|
31 |
+
# Conversation route
|
32 |
+
prompt = user_name + ": " + user_input + "\n" + bot_name+ ": "
|
33 |
+
conversation += prompt # allows for context
|
34 |
+
# fetch the response from open AI api
|
35 |
+
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
|
36 |
+
response_str = response["choices"][0]["text"].replace("\n", "")
|
37 |
+
response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
|
38 |
|
39 |
+
conversation += response_str + "\n"
|
40 |
+
|
41 |
+
gpt_response = response_str
|
42 |
+
print("Error")
|
43 |
+
|
44 |
|
45 |
return whisper_text, gpt_response
|
46 |
|