Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,12 @@ def generate_response(prompt):
|
|
22 |
}
|
23 |
|
24 |
response = requests.post(gpt_url, json=data, headers=headers)
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Создание интерфейса чата с использованием Gradio
|
28 |
def chat_interface(messages):
|
|
|
22 |
}
|
23 |
|
24 |
response = requests.post(gpt_url, json=data, headers=headers)
|
25 |
+
|
26 |
+
# Проверяем наличие ключа 'choices' в ответе
|
27 |
+
if "choices" in response.json():
|
28 |
+
return response.json()["choices"][0]["text"].strip()
|
29 |
+
else:
|
30 |
+
return "Error: Unable to retrieve response."
|
31 |
|
32 |
# Создание интерфейса чата с использованием Gradio
|
33 |
def chat_interface(messages):
|