Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,15 +4,22 @@ import json
|
|
4 |
|
5 |
URL = "198.175.88.52"
|
6 |
myport = "8080"
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
def text_gen(url, prompt):
|
10 |
resp = requests.post(url, data=json.dumps(prompt))
|
11 |
return resp.text
|
12 |
-
|
13 |
demo = gr.Interface(
|
14 |
fn=text_gen,
|
15 |
-
|
16 |
outputs=["text"])
|
17 |
|
18 |
demo.launch(share=True)
|
|
|
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 127.0.0.1:8080/generate -X POST -d '{\"inputs\":\"${prompt}\",\"parameters\":{\"max_new_tokens\":32}}' -H 'Content-Type: application/json'"
|
11 |
+
|
12 |
+
url_input = gr.inputs.Textbox(label="URL", value=g2url, visible=False)
|
13 |
+
prompt_input = gr.inputs.Textbox(label="Prompt", value=prompt, visible=True)
|
14 |
+
outputs = gr.outputs.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=["text"])
|
24 |
|
25 |
demo.launch(share=True)
|