Update app.py
Browse files
app.py
CHANGED
|
@@ -36,9 +36,14 @@ def generate(forr, ver=13, doptb=""):
|
|
| 36 |
data = response.json() # Используем response.json() вместо json.loads()
|
| 37 |
|
| 38 |
if 'choices' in data and len(data['choices']) > 0:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
elif 'error' in data:
|
| 43 |
error_message = data['error']['message']
|
| 44 |
print(f'Ошибка: {error_message}')
|
|
|
|
| 36 |
data = response.json() # Используем response.json() вместо json.loads()
|
| 37 |
|
| 38 |
if 'choices' in data and len(data['choices']) > 0:
|
| 39 |
+
content = data['choices'][0]['message'].get('content')
|
| 40 |
+
if content is not None:
|
| 41 |
+
congratulation = content.strip()
|
| 42 |
+
print(f"Генерация успешна: '{forr}' с версией '{ver}'")
|
| 43 |
+
return congratulation
|
| 44 |
+
else:
|
| 45 |
+
print(f'Пустой ответ от сервера для запроса: "{forr}"')
|
| 46 |
+
return "Сервер вернул пустой ответ. Попробуйте изменить параметры запроса."
|
| 47 |
elif 'error' in data:
|
| 48 |
error_message = data['error']['message']
|
| 49 |
print(f'Ошибка: {error_message}')
|