Rooni commited on
Commit
9caabf4
·
1 Parent(s): 15697bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -8,7 +8,7 @@ import os
8
  # functions
9
  def generate(description, model, max_tokens):
10
  if not description or not model:
11
- return ""
12
 
13
  headers = {
14
  'Content-Type': 'application/json',
@@ -27,14 +27,14 @@ def generate(description, model, max_tokens):
27
 
28
  if 'choices' in data and len(data['choices']) > 0:
29
  command = data['choices'][0]['message']['content'].strip()
30
- return command
31
  elif 'error' in data:
32
  error_message = data['error']['message']
33
  print(f'Ошибка: {error_message}')
34
- return f"Ошибка сервера! ({error_message})"
35
  else:
36
  print(f'Не удалось сгенерировать текст. Повторите попытку позже...')
37
- return "Неизвестная ошибка!"
38
 
39
 
40
  # css
@@ -61,9 +61,9 @@ with gr.Blocks(css=css) as vui:
61
  with gr.Column(scale=2):
62
  with gr.Tab("Ответ"):
63
  text_output = gr.Markdown(show_label=False, value="**Здравствуйте!** Чем я могу Вам помочь сегодня?")
64
- gr.Acc
65
-
66
- text_button.click(generate, inputs=[promt, model, max_tokens], outputs=text_output)
67
 
68
  #end
69
  vui.queue(api_open=False).launch()
 
8
  # functions
9
  def generate(description, model, max_tokens):
10
  if not description or not model:
11
+ return "", ""
12
 
13
  headers = {
14
  'Content-Type': 'application/json',
 
27
 
28
  if 'choices' in data and len(data['choices']) > 0:
29
  command = data['choices'][0]['message']['content'].strip()
30
+ return command, command
31
  elif 'error' in data:
32
  error_message = data['error']['message']
33
  print(f'Ошибка: {error_message}')
34
+ return f"**Ошибка сервера!**\n\n```\n{error_message}\n```", f"Ошибка сервера!\n\n{error_message}"
35
  else:
36
  print(f'Не удалось сгенерировать текст. Повторите попытку позже...')
37
+ return "**Неизвестная ошибка!**", "Неизвестная ошибка!"
38
 
39
 
40
  # css
 
61
  with gr.Column(scale=2):
62
  with gr.Tab("Ответ"):
63
  text_output = gr.Markdown(show_label=False, value="**Здравствуйте!** Чем я могу Вам помочь сегодня?")
64
+ with gr.Accordion(label="Без Markdown", opedn=False):
65
+ text_output_nm = gr.Textbox(show_label=False, value="**Здравствуйте!** Чем я могу Вам помочь сегодня?")
66
+ text_button.click(generate, inputs=[promt, model, max_tokens], outputs=[text_output, text_output_nm])
67
 
68
  #end
69
  vui.queue(api_open=False).launch()