Xmaster6y commited on
Commit
e361a7d
1 Parent(s): d2ad521

Better examples

Browse files
Files changed (1) hide show
  1. src/call_interface.py +27 -1
src/call_interface.py CHANGED
@@ -1,7 +1,33 @@
1
  """Call the inference API of HF.
2
  """
3
 
 
 
4
  import gradio as gr
5
 
6
 
7
- interface = gr.load("yp-edu/gpt2-stockfish-debug", src="models")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  """Call the inference API of HF.
2
  """
3
 
4
+ import huggingface_hub
5
+
6
  import gradio as gr
7
 
8
 
9
+
10
+ model_name = "yp-edu/gpt2-stockfish-debug"
11
+
12
+ headers = {"X-Wait-For-Model": "true"}
13
+ client = huggingface_hub.InferenceClient(
14
+ model=model_name, headers=headers
15
+ )
16
+
17
+ inputs = gr.Textbox(label="Prompt")
18
+ outputs = gr.Textbox(label="Completion")
19
+ examples = [
20
+ "FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1\nMOVE:",
21
+ "FEN: r2q1rk1/1p3ppp/4bb2/p2p4/5B2/1P1P4/1PPQ1PPP/R3R1K1 w - - 1 17\nMOVE:",
22
+ "FEN: 4r1k1/1p1b1ppp/8/8/3P4/2P5/1q3PPP/6K1 b - - 0 28\nMOVE:",
23
+ ]
24
+ fn = gr.external_utils.text_generation_wrapper(client)
25
+
26
+
27
+ interface = gr.Interface(
28
+ fn=fn,
29
+ inputs=inputs,
30
+ outputs=outputs,
31
+ title=f"Call to {model_name}",
32
+ examples=examples,
33
+ )