Rooni commited on
Commit
5aae4d6
1 Parent(s): 86c9f85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -5,6 +5,9 @@ import os
5
  import time
6
 
7
  def generate(description, model, max_tokens):
 
 
 
8
  headers = {
9
  'Content-Type': 'application/json',
10
  'Authorization': f'Bearer {os.getenv("API_KEY")}'
@@ -30,14 +33,11 @@ def generate(description, model, max_tokens):
30
  else:
31
  print(f'Не удалось сгенерировать текст. Повторная попытка...')
32
  time.sleep(1)
33
-
34
- iface = gr.Interface(
35
- fn=generate,
36
- inputs=[
37
- gr.Textbox(label="Запрос", placeholder="Введите текст...", state="active" if gr.Textbox().data != "" else "disabled"),
38
- gr.Radio(show_label=True, label="Модель", interactive=True, choices=["gpt-3.5-turbo", "gpt-3.5-turbo-16k"], value="gpt-3.5-turbo"),
39
- gr.Slider(show_label=True, label="Максимум токенов", minimum=100, maximum=15000, value=10000, step=1)
40
- ],
41
- outputs=gr.Textbox(label="Ответ")
42
- )
43
- iface.launch()
 
5
  import time
6
 
7
  def generate(description, model, max_tokens):
8
+ if not description:
9
+ return "Введите запрос"
10
+
11
  headers = {
12
  'Content-Type': 'application/json',
13
  'Authorization': f'Bearer {os.getenv("API_KEY")}'
 
33
  else:
34
  print(f'Не удалось сгенерировать текст. Повторная попытка...')
35
  time.sleep(1)
36
+
37
+ iface = gr.Interface(fn=generate, inputs=[
38
+ gr.Textbox(label="Запрос"),
39
+ gr.Radio(show_label=True, label="Модель", interactive=True, choices=["gpt-3.5-turbo", "gpt-3.5-turbo-16k"], value="gpt-3.5-turbo"),
40
+ gr.Slider(show_label=True, label="Максимум токенов", minimum=100, maximum=15000, value=10000, step=1)
41
+ ], outputs=gr.Textbox(label="Ответ"))
42
+
43
+ iface.launch(share=True, live=True, inline=False, debug=True, blocking=True)