File size: 554 Bytes
436c3a3
543fe4a
436c3a3
dd652af
436c3a3
543fe4a
436c3a3
de0bfd0
 
8261f3e
436c3a3
543fe4a
436c3a3
0b123a0
de0bfd0
 
436c3a3
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import loop

MODEL_ID = "TinyLlama/TinyLlama_v1.1_math_code"

handler = loop.EndpointHandler(MODEL_ID)

def respond(prompt, grammar, max_new_tokens, max_time):
    args = { "inputs": prompt, "grammar": grammar, "max-new-tokens": max_new_tokens, "max-time": max_time }
    return handler(args)[0]

demo = gr.Interface(
    respond,
    inputs=["textarea", "textarea"],
    outputs=["textarea"],
    additional_inputs=[gr.Number(value=512, precision=0), gr.Number(value=30, precision=0)]
)

if __name__ == "__main__":
    demo.launch()