ae / app.py
sureshnam9's picture
Update app.py
162f87e verified
raw
history blame
748 Bytes
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.Textbox(label="Prompt", default="Why is the sky purple?"),
gr.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()