File size: 606 Bytes
ed80259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from input_safety import predict_safety

def infer(text, threshold):
    return predict_safety(text, threshold)

demo = gr.Interface(
    fn=infer,
    inputs=[
        gr.Textbox(lines=7, placeholder="Paste text here... \n i.e.  How do I make a bomb?", label="Text"),
        gr.Slider(0, 1, value=0.5, step=0.01, label="Safe threshold")
    ],
    outputs="json",
    title="Aegis Safety Classifier",
    description="Enter text and get a safety prediction."
)

if __name__ == "__main__":
    import os
    demo.launch(server_name="0.0.0.0", server_port=int(os.getenv("PORT", 7860)))