Rooni commited on
Commit
715e65d
·
1 Parent(s): 8d13b21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  import requests
3
  import json
4
  import os
 
5
 
6
  def generate_minecraft_command(description):
7
  headers = {
@@ -20,14 +21,17 @@ def generate_minecraft_command(description):
20
 
21
  if 'choices' in data and len(data['choices']) > 0:
22
  command = data['choices'][0]['message']['content'].strip()
23
- return command
 
 
 
24
  elif 'error' in data:
25
  error_message = data['error']['message']
26
- return f'<b>Ошибка:</b> {error_message}'
27
  else:
28
- return f'<b>Не удалось сгенерировать команду.</b> {data}'
29
 
30
  iface = gr.Interface(fn=generate_minecraft_command, inputs=[
31
  gr.Textbox(label="Запрос")
32
- ], outputs=gr.Textbox(label="Ответ", html=True), title="GPT")
33
  iface.launch()
 
2
  import requests
3
  import json
4
  import os
5
+ import markdown2 # Не забудьте импортировать библиотеку
6
 
7
  def generate_minecraft_command(description):
8
  headers = {
 
21
 
22
  if 'choices' in data and len(data['choices']) > 0:
23
  command = data['choices'][0]['message']['content'].strip()
24
+
25
+ # Преобразование Markdown в HTML
26
+ command_html = markdown2.markdown(command)
27
+ return command_html
28
  elif 'error' in data:
29
  error_message = data['error']['message']
30
+ return f'Ошибка: {error_message}'
31
  else:
32
+ return f'Не удалось сгенерировать команду. {data}'
33
 
34
  iface = gr.Interface(fn=generate_minecraft_command, inputs=[
35
  gr.Textbox(label="Запрос")
36
+ ], outputs=gr.Textbox(label="Ответ", type="html"), title="GPT") # Указываем тип вывода как "html"
37
  iface.launch()