File size: 734 Bytes
d2ad521
 
 
e361a7d
 
d2ad521
 
 
e361a7d
 
 
 
 
 
 
 
 
 
 
 
 
 
f4a47cd
e361a7d
 
 
 
 
 
 
 
 
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
"""Call the inference API of HF.
"""

import huggingface_hub

import gradio as gr


model_name = "yp-edu/gpt2-stockfish-debug"

headers = {"X-Wait-For-Model": "true"}
client = huggingface_hub.InferenceClient(
    model=model_name, headers=headers
)

inputs = gr.Textbox(label="Prompt")
outputs = gr.Textbox(label="Completion")
examples = [
    "FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1\nMOVE:",
    "FEN: r2q1rk1/1p3ppp/4bb2/p2p4/5B2/1P1P4/1PPQ1PPP/R3R1K1 w - - 1 17\nMOVE:",
    "FEN: 4r1k1/1p1b1ppp/8/8/3P4/2P5/1q3PPP/6K1 b - - 0 28\nMOVE:",
]
fn = client.text_generation


interface = gr.Interface(
    fn=fn,
    inputs=inputs,
    outputs=outputs,
    title=f"Call to {model_name}",
    examples=examples,
)