File size: 847 Bytes
8a776d7
 
 
 
 
 
 
 
 
 
 
 
 
a74e752
 
 
 
8a776d7
9bba9ff
8a776d7
 
 
 
 
 
 
a74e752
8a776d7
 
 
 
 
 
 
 
9bba9ff
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
29
30
31
32
33
34
35
36
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)