Spaces:
Sleeping
Sleeping
File size: 762 Bytes
12e34fc 91367ff 4be9993 d8e0a07 91367ff 4be9993 d94f2c6 4be9993 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
import requests
import json
def text_gen(prompt, url):
data = {
"inputs": prompt
}
try:
response = requests.post(url, data=json.dumps(data), headers={'Content-Type': 'application/json'})
response.raise_for_status()
return response.text
except requests.exceptions.RequestException as e:
return f"Error: {e}"
demo = gr.Interface(
fn=text_gen,
inputs=[
gr.inputs.Textbox(label="Prompt", default="Why is the sky purple?"),
gr.inputs.Textbox(label="URL", default="http://198.175.88.52:8080/generate")
],
outputs=gr.outputs.Textbox(label="Response"),
title="Text Generation",
description="Enter a prompt and a URL to generate text."
)
demo.launch()
|