Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,25 +2,26 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
import json
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
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 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
|
|
|
2 |
import requests
|
3 |
import json
|
4 |
|
5 |
+
def text_gen(prompt, url):
|
6 |
+
data = {
|
7 |
+
"inputs": prompt
|
8 |
+
}
|
9 |
+
try:
|
10 |
+
response = requests.post(url, data=json.dumps(data), headers={'Content-Type': 'application/json'})
|
11 |
+
response.raise_for_status()
|
12 |
+
return response.text
|
13 |
+
except requests.exceptions.RequestException as e:
|
14 |
+
return f"Error: {e}"
|
|
|
|
|
|
|
|
|
15 |
|
16 |
demo = gr.Interface(
|
17 |
fn=text_gen,
|
18 |
+
inputs=[
|
19 |
+
gr.inputs.Textbox(label="Prompt", default="Why is the sky purple?"),
|
20 |
+
gr.inputs.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()
|