Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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':
|
15 |
-
'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()
|