Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import os
|
|
6 |
def gpt3_turbo(image=None, text=None):
|
7 |
|
8 |
api_key = os.getenv("API_KEY")
|
|
|
9 |
|
10 |
# Формируем данные для отправки запроса
|
11 |
data = {}
|
@@ -20,14 +21,14 @@ def gpt3_turbo(image=None, text=None):
|
|
20 |
'Content-Type': 'application/json',
|
21 |
'Authorization': f'Bearer {api_key}'
|
22 |
}
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
result = response.json()
|
28 |
return result['choices'][0]['text']
|
29 |
-
|
30 |
-
return "Ошибка при получении ответа от
|
31 |
|
32 |
# Создаем интерфейс Gradio
|
33 |
iface = gr.Interface(
|
|
|
6 |
def gpt3_turbo(image=None, text=None):
|
7 |
|
8 |
api_key = os.getenv("API_KEY")
|
9 |
+
endpoint = os.getenv("BASE_URL")
|
10 |
|
11 |
# Формируем данные для отправки запроса
|
12 |
data = {}
|
|
|
21 |
'Content-Type': 'application/json',
|
22 |
'Authorization': f'Bearer {api_key}'
|
23 |
}
|
24 |
+
|
25 |
+
try:
|
26 |
+
response = requests.post(endpoint, headers=headers, json={"prompt": data, "max_tokens": 100, "model": 'gpt-3.5-turbo'})
|
27 |
+
response.raise_for_status() # Проверка статуса ответа
|
28 |
result = response.json()
|
29 |
return result['choices'][0]['text']
|
30 |
+
except requests.RequestException as e:
|
31 |
+
return f"Ошибка при получении ответа от модели: {e}"
|
32 |
|
33 |
# Создаем интерфейс Gradio
|
34 |
iface = gr.Interface(
|