Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,26 +2,24 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
import json
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
demo = gr.Interface(
|
17 |
fn=text_gen,
|
18 |
-
|
19 |
-
|
20 |
-
gr.Textbox(label="URL", default="http://198.175.88.52:8080/generate")
|
21 |
-
],
|
22 |
-
outputs=gr.outputs.Textbox(label="Response"),
|
23 |
-
title="Text Generation",
|
24 |
-
description="Enter a prompt and a URL to generate text."
|
25 |
-
)
|
26 |
|
27 |
-
demo.launch()
|
|
|
2 |
import requests
|
3 |
import json
|
4 |
|
5 |
+
URL = "198.175.88.52"
|
6 |
+
myport = "8080"
|
7 |
+
g2url = f"http://{URL}:{myport}/generate"
|
8 |
+
|
9 |
+
prompt="Why is the sky purple"
|
10 |
+
#build_curl_prompt="curl ${g2url} -X POST -d '{\"inputs\":\"${prompt}\",\"parameters\":{\"max_new_tokens\":32}}' -H 'Content-Type: application/json'"
|
11 |
+
|
12 |
+
url_input = gr.Textbox(label="URL", value=g2url, visible=True)
|
13 |
+
prompt_input = gr.Textbox(label="Prompt", value=prompt, visible=True)
|
14 |
+
outputs = gr.Textbox(label="Generated Text")
|
15 |
+
|
16 |
+
def text_gen(url, prompt):
|
17 |
+
resp = requests.post(url, data=json.dumps(prompt))
|
18 |
+
return resp.text
|
19 |
|
20 |
demo = gr.Interface(
|
21 |
fn=text_gen,
|
22 |
+
inputs=[url_input, prompt_input],
|
23 |
+
outputs=[outputs])
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
demo.launch(share=True)
|