Rooni commited on
Commit
dd6ed94
·
verified ·
1 Parent(s): 49805bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
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
- congratulation = data['choices'][0]['message']['content'].strip()
40
- print(f"Генерация успешна: '{forr}' с версией '{ver}'")
41
- return congratulation
 
 
 
 
 
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}')