estellea commited on
Commit
864964a
1 Parent(s): c51b668

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import json
4
+
5
+ def text_gen(url, prompt):
6
+ headers = {'Content-Type': 'application/json'}
7
+ payload = {'inputs': prompt, 'parameters': {'max_new_tokens': 32}}
8
+ resp = requests.post(url, data=json.dumps(payload), headers=headers)
9
+ return resp.text
10
+
11
+ URL = "198.175.88.247"
12
+ myport = "80"
13
+ g2url = f"http://{URL}:{myport}/generate"
14
+
15
+ url_input = gr.Textbox(label="URL", value=g2url, visible=True)
16
+ prompt_input = gr.Textbox(label="Prompt", value="Why is the sky purple?", visible=True)
17
+ outputs = gr.Textbox(label="Generated Text")
18
+
19
+ demo = gr.Interface(
20
+ fn=text_gen,
21
+ inputs=[url_input, prompt_input],
22
+ outputs=[outputs],
23
+ title="Text Generation Demo"
24
+ )
25
+
26
+ demo.launch()