Spaces:
Build error
Build error
File size: 1,177 Bytes
24719eb 94ffd51 e48a93d 24719eb e48a93d |
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 37 38 39 40 41 42 43 44 45 46 47 |
#inference api call template
import requests
def query(payload, model_id, api_token):
headers = {"Authorization": f"Bearer {api_token}"}
API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
model_id = "distilbert-base-uncased"
api_token = "hf_XXXXXXXX" # get yours at hf.co/settings/tokens
data = query("The goal of life is [MASK].", model_id, api_token)
#u0dar before changing page!
#mkvapicalljs-format into and merge this call into the adjacent codeblock templates
const response = await fetch("https://hazzzardous-rwkv-instruct.hf.space/run/predict", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: [
"hello world",
"Freeform",
40,
0.9,
0.85,
"<|endoftext|>",
0,
]
})
});
const data = await data.json();
#gradioblocks interface template
gradio as gr
def greet(name):
return "Hello " + name
# We instantiate the Textbox class
textbox = gr.Textbox(label="Type your name here:", placeholder="John Doe", lines=2)
gr.Interface(fn=greet, inputs=textbox, outputs="text").launch()
|