Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
5f283d9
1
Parent(s):
bbef3ac
app.py
CHANGED
|
@@ -18,6 +18,9 @@ import gradio as gr
|
|
| 18 |
# except Exception as e:
|
| 19 |
# ex = e
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
import requests
|
| 22 |
def f(text):
|
| 23 |
try:
|
|
@@ -27,8 +30,8 @@ def f(text):
|
|
| 27 |
payload = {
|
| 28 |
"context": context,
|
| 29 |
"token_max_length": 512,
|
| 30 |
-
"temperature":
|
| 31 |
-
"top_p":
|
| 32 |
}
|
| 33 |
response = requests.post("http://api.vicgalle.net:5000/generate", params=payload).json()
|
| 34 |
|
|
@@ -36,7 +39,6 @@ def f(text):
|
|
| 36 |
return "error: \n"+str(e)
|
| 37 |
return response['text']
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
iface = gr.Interface(fn=f, inputs="text", outputs="text")
|
| 42 |
iface.launch(enable_queue=True)
|
|
|
|
| 18 |
# except Exception as e:
|
| 19 |
# ex = e
|
| 20 |
|
| 21 |
+
temperature = gr.inputs.Slider(minimum=0, maximum=1.5, step=0.1, default=0.9, label="temperature")
|
| 22 |
+
top_p = gr.inputs.Slider(minimum=0, maximum=1.0, step=0.1, default=0.9, label="top_p")
|
| 23 |
+
|
| 24 |
import requests
|
| 25 |
def f(text):
|
| 26 |
try:
|
|
|
|
| 30 |
payload = {
|
| 31 |
"context": context,
|
| 32 |
"token_max_length": 512,
|
| 33 |
+
"temperature": temperature,
|
| 34 |
+
"top_p": top_p,
|
| 35 |
}
|
| 36 |
response = requests.post("http://api.vicgalle.net:5000/generate", params=payload).json()
|
| 37 |
|
|
|
|
| 39 |
return "error: \n"+str(e)
|
| 40 |
return response['text']
|
| 41 |
|
|
|
|
| 42 |
|
| 43 |
iface = gr.Interface(fn=f, inputs="text", outputs="text")
|
| 44 |
iface.launch(enable_queue=True)
|