Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from blindbox.requests import SecureSession | |
| DEMO_SERVER = "4.208.9.167:80" | |
| def run_query( prompt): | |
| POLICY = "./cce_policy.txt" | |
| try: | |
| with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session: | |
| res = secure_session.post(endpoint="/generate", json={"input_text": prompt}) | |
| return("✅ Query successful\n" + res.text) | |
| except Exception as err: | |
| return(f"⛔ Query failed!\n{err}") | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("<h1><center>🔒Confidential code generation with BlindBox and Santacoder</center></h1>") | |
| gr.Markdown("<br><p>You can use this demo to send a function definition to BigCode's open-source Santacoder model and get back an auto-completed function.</p>") | |
| gr.Markdown("<br><p>The model is deployed within a highly-isolated Trusted Execution Environment, meaning that we, as the service provider, have no access to the data sent to this model!</p>") | |
| with gr.Column(): | |
| prompt = gr.Textbox(lines=2, placeholder="Enter function definition here e.g. def print_name(name):") | |
| with gr.Column(): | |
| trigger = gr.Button("Test query") | |
| with gr.Column(): | |
| output = gr.Textbox(placeholder="Output", label="See the output of your query here") | |
| trigger.click(fn=run_query, inputs=[prompt], outputs=output) | |
| if __name__ == "__main__": | |
| demo.launch() | |