Spaces:
Sleeping
Sleeping
File size: 712 Bytes
12e34fc 3845b7e 3ad9283 7e0b9e8 0169924 3ad9283 66ac57b 3ad9283 66ac57b 3ad9283 7e0b9e8 3ad9283 14d2b8b 3ad9283 d8e0a07 91367ff 3ad9283 3845b7e 3ad9283 |
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 |
import gradio as gr
import requests
import json
URL = "198.175.88.52"
myport = "80"
g2url = f"http://{URL}:{myport}/generate"
prompt="Why is the sky purple"
build_curl_prompt="curl ${g2url} -X POST -d '{\"inputs\":\"${prompt}\",\"parameters\":{\"max_new_tokens\":32}}' -H 'Content-Type: application/json'"
url_input = gr.Textbox(label="URL", value=g2url, visible=True)
prompt_input = gr.Textbox(label="Prompt", value=prompt, visible=True)
outputs = gr.Textbox(label="Generated Text")
def text_gen(url, prompt):
resp = requests.post(g2url, data=json.dumps(prompt))
return resp.text
demo = gr.Interface(
fn=text_gen,
inputs=[url_input, prompt_input],
outputs=[outputs])
demo.launch() |