Rooni commited on
Commit
2c6863b
1 Parent(s): e586c5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -2,10 +2,6 @@ import gradio as gr
2
  import requests
3
  import json
4
  import os
5
- import markdown2
6
- from pygments import highlight
7
- from pygments.lexers import get_lexer_by_name
8
- from pygments.formatters import HtmlFormatter
9
 
10
  def generate_minecraft_command(description):
11
  headers = {
@@ -24,16 +20,7 @@ def generate_minecraft_command(description):
24
 
25
  if 'choices' in data and len(data['choices']) > 0:
26
  command = data['choices'][0]['message']['content'].strip()
27
-
28
- # Преобразование Markdown в HTML
29
- command_html = markdown2.markdown(command)
30
-
31
- # Подсветка синтаксиса кода
32
- lexer = get_lexer_by_name("html", stripall=True)
33
- formatter = HtmlFormatter(style="colorful", full=True, noclasses=True)
34
- highlighted_code = highlight(command, lexer, formatter)
35
-
36
- return highlighted_code
37
  elif 'error' in data:
38
  error_message = data['error']['message']
39
  return f'Ошибка: {error_message}'
@@ -42,5 +29,5 @@ def generate_minecraft_command(description):
42
 
43
  iface = gr.Interface(fn=generate_minecraft_command, inputs=[
44
  gr.Textbox(label="Запрос")
45
- ], outputs=gr.Code(label="Ответ", language="html"), title="GPT")
46
- iface.launch()
 
2
  import requests
3
  import json
4
  import os
 
 
 
 
5
 
6
  def generate_minecraft_command(description):
7
  headers = {
 
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'Ошибка: {error_message}'
 
29
 
30
  iface = gr.Interface(fn=generate_minecraft_command, inputs=[
31
  gr.Textbox(label="Запрос")
32
+ ], outputs=gr.Textbox(label="Ответ"), title="GPT")
33
+ iface.launch()