Rooni commited on
Commit
814439a
1 Parent(s): 0d85215

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -3,7 +3,7 @@ import requests
3
  import json
4
  import os
5
 
6
- def generate(description):
7
  headers = {
8
  'Content-Type': 'application/json',
9
  'Authorization': f'Bearer {os.getenv("API_KEY")}'
@@ -11,8 +11,8 @@ def generate(description):
11
 
12
  payload = {
13
  'messages': [{'role': 'system', 'content': f'{description}'}],
14
- 'max_tokens': 10000,
15
- 'model': os.getenv("MODEL")
16
  }
17
 
18
  response = requests.post(os.getenv("BASE_URL"), headers=headers, json=payload)
@@ -28,6 +28,8 @@ def generate(description):
28
  return f'Не удалось сгенерировать текст. {data}'
29
 
30
  iface = gr.Interface(fn=generate, inputs=[
31
- gr.Textbox(label="Запрос")
 
 
32
  ], outputs=gr.Textbox(label="Ответ"), title="GPT")
33
  iface.launch()
 
3
  import json
4
  import os
5
 
6
+ def generate(description, model, max_tokens):
7
  headers = {
8
  'Content-Type': 'application/json',
9
  'Authorization': f'Bearer {os.getenv("API_KEY")}'
 
11
 
12
  payload = {
13
  'messages': [{'role': 'system', 'content': f'{description}'}],
14
+ 'max_tokens': max_tokens,
15
+ 'model': model
16
  }
17
 
18
  response = requests.post(os.getenv("BASE_URL"), headers=headers, json=payload)
 
28
  return f'Не удалось сгенерировать текст. {data}'
29
 
30
  iface = gr.Interface(fn=generate, inputs=[
31
+ gr.Textbox(label="Запрос"),
32
+ gr.Radio(show_label=True, label="Модель", interactive=True, choices=["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4"], value="gpt-3.5-turbo"),
33
+ gr.Slider(show_label=True, label="Максимум токенов", minimum=100, maximum=15000, value=10000, step=1)
34
  ], outputs=gr.Textbox(label="Ответ"), title="GPT")
35
  iface.launch()