Spaces:
Runtime error
Runtime error
import gradio as gr | |
import requests | |
import json | |
def text_gen(url, prompt): | |
headers = {'Content-Type': 'application/json'} | |
payload = {'inputs': prompt, 'parameters': {'max_new_tokens': 32}} | |
resp = requests.post(url, data=json.dumps(payload), headers=headers) | |
return resp.text | |
URL = "198.175.88.247" | |
myport = "80" | |
g2url = f"http://{URL}:{myport}/generate" | |
url_input = gr.Textbox(label="URL", value=g2url, visible=True) | |
prompt_input = gr.Textbox(label="Prompt", value="Why is the sky purple?", visible=True) | |
outputs = gr.Textbox(label="Generated Text") | |
demo = gr.Interface( | |
fn=text_gen, | |
inputs=[url_input, prompt_input], | |
outputs=[outputs], | |
title="Text Generation Demo" | |
) | |
demo.launch() |