import gradio as gr from blindbox.requests import SecureSession DEMO_SERVER = "4.208.9.167:80" text = "

šŸŽ… SantaCoder with BlindBox: Private Code Generation

This is our demo for our article on deploying code generation LLM models with BlindBox. The user input is protected during computation by leveraging state-of-the-art Confidental Computing technologies. This means that data sent to Santacoder model is never accessible to the service provider during computation- private code remains private!

You can see how we deployed the model in the integration section of our documentation!

āš ļø BlindBox is still under development. Do not test with production data!

" bullets = "

Features coming soon:

" token_info = "

Find out more about the MAA attesation token here!" def run_query( server, prompt): if server == "Non-confidential VM server": return ("ā›” Error: you can only connect to an application running on a Confidential VM") POLICY = "./cce_policy.txt" if prompt == None: return ("ā›” Error: please provide input code") message = "\n\nāœ… Secure query succesful" message2 = "āœ… Attestation validated\n" try: with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session: res = secure_session.post(endpoint="/generate", json={"input_text": prompt}) cleaned = res.text.replace('\\n', '\n').split('\n\n')[0].split(':"')[1] cleaned = cleaned.replace('\\', '') return(cleaned + message, message2 + secure_session.jwt) except Exception as err: return(f"ā›” Query failed!\n{err}") demo = gr.Blocks(css=".gradio-container { background-color: #20233fff;} .app.svelte-1mya07g.svelte-1mya07g {max-width: 1100px !important;}") with demo: gr.Markdown(value=text) gr.Markdown(value=bullets) _, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1) with colum_2: prompt = gr.Code(lines=3, language="python", label="Input code", value="def hello_name(name):") with gr.Accordion("Advanced settings", open=False): server = gr.Radio( ["Authentic confidential VM server", "Non-confidential VM server"], label="Test connections to secure and insecure servers" ) trigger = gr.Button(label="Run query") with gr.Column(): output = gr.Textbox(placeholder="Output", label="Output") with gr.Accordion("Attestation token (signed JWT token): ", open=False): output2 = gr.Textbox(placeholder="Attestation token", label="Output") gr.Markdown(value=token_info) trigger.click(fn=run_query, inputs=[server, prompt], outputs=[output, output2]) gr.HTML(label="Contact", value="contact") if __name__ == "__main__": demo.launch()