|
import gradio as gr |
|
|
|
import requests |
|
|
|
API_URL = "https://t1q6ks6fusyg1qq7.us-east-1.aws.endpoints.huggingface.cloud" |
|
headers = { |
|
"Accept" : "application/json", |
|
"Content-Type": "application/json" |
|
} |
|
|
|
def return_text(txt): |
|
response = requests.post(API_URL, headers=headers, json={ |
|
"inputs": txt, |
|
"parameters": { |
|
"temperature": 0.7, |
|
"max_new_tokens": 512 |
|
} |
|
}) |
|
return response.json()[0]['generated_text'] |
|
|
|
|
|
demo = gr.Blocks() |
|
|
|
with demo: |
|
gr.Markdown( |
|
""" |
|
# Generate text from snorkelai/Snorkel-Mistral-PairRM-DPO with default parameters! |
|
Start typing below to see the output. |
|
""" |
|
) |
|
input = gr.Textbox(placeholder="[INST] Tell me an interesting story [/INST]") |
|
output = gr.Textbox() |
|
|
|
input.change(fn=return_text, inputs=input, outputs=output) |
|
|
|
demo.launch(share=True) |