lauro1 commited on
Commit
2535e53
β€’
1 Parent(s): 38ba92a

updated version feedback

Browse files
Files changed (1) hide show
  1. app.py +5 -19
app.py CHANGED
@@ -2,45 +2,31 @@ import gradio as gr
2
  from blindbox.requests import SecureSession
3
 
4
  DEMO_SERVER = "4.208.9.167:80"
5
- text = "<h1 style='text-align: center; color: white;'>πŸŽ… SantaCoder with <span style='color: #f0ba2d;'>BlindBox:</span> Private Code Generation </h1><p style='text-align: left; color: white;'>This is our demo for our <a style='color: #f0ba2d;', href='https://blog-mithril-security.ghost.io/ai-assisted-code-generation-with-privacy-guarantees-securely-deploy-santacoder-with-blindbox'>article</a> on deploying code generation LLM models with BlindBox. The user input is <a style='color: #f0ba2d;', href='https://blindbox.mithrilsecurity.io/en/latest/docs/getting-started/confidential_computing/'>protected during computation</a> by leveraging state-of-the-art <a style='color: #f0ba2d;', href='https://www.ibm.com/topics/confidential-computing'> Confidental Computing technologies.</a> This means that data sent to Santacoder model is never accessible to the service provider during computation- private code remains private!</p><p style='text-align: left; color: white;'>You can see how we deployed the model in the integration section of our <a style='color: #f0ba2d;', href='https://blindbox.mithrilsecurity.io/en/latest/docs/how-to-guides/santacoder/'>documentation!</a></p><p style='text-align: left; color: white;'>⚠️ BlindBox is still under development. Do not test with production data!</p>"
6
- bullets = "<ul><li style='color: white;'>βœ… Connection verified by <a style='color: #f0ba2d;', href='https://blindbox.mithrilsecurity.io/en/latest/docs/security/attestation'>attestation</a></li><li style='color: white;'>βœ… Application deployed on Confidential VM</li></ul><p style='color: white;'>Features coming soon:</p><ul><li style='color: white;'>βŒ› TLS</li><li style='color: white;'>βŒ› Network isolation</li></ul>"
7
- token_info = "<p style='color: white;'> Find out more about the MAA attesation token <a style='color: #f0ba2d;', href='https://blindbox.mithrilsecurity.io/en/latest/docs/security/attestation/#maa-attestation-token'>here!</a>"
8
- def run_query( server, prompt):
9
- if server == "Non-confidential VM server":
10
- return (["β›” Error: you can only connect to an application running on a Confidential VM", "β›” Error: attesation failed"])
11
  POLICY = "./cce_policy.txt"
12
  if prompt == None:
13
- return (["β›” Error: please provide input code", "β›” Error: please provide input code"])
14
  message = "\n\nβœ… Secure query succesful"
15
- message2 = "βœ… Attestation validated\n"
16
  try:
17
  with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
18
  res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
19
  cleaned = res.text.replace('\\n', '\n').split('\n\n')[0].split(':"')[1]
20
  cleaned = cleaned.replace('\\', '')
21
- return(cleaned + message, message2 + secure_session.jwt)
22
  except Exception as err:
23
  return(f"β›” Query failed!\n{err}")
24
 
25
  demo = gr.Blocks(css=".gradio-container { background-color: #20233fff;} .app.svelte-1mya07g.svelte-1mya07g {max-width: 900px !important;}")
26
  with demo:
27
  gr.Markdown(value=text)
28
- gr.Markdown(value=bullets)
29
  _, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
30
  with colum_2:
31
  prompt = gr.Code(lines=3, language="python", label="Input code", value="def hello_name(name):")
32
-
33
- with gr.Accordion("Advanced settings", open=False):
34
- server = gr.Radio(
35
- ["Authentic confidential VM server", "Non-confidential VM server"], label="Test connections to secure and insecure servers"
36
- )
37
  trigger = gr.Button(label="Run query")
38
  with gr.Column():
39
  output = gr.Textbox(placeholder="Output", label="Output")
40
- with gr.Accordion("Attestation token (signed JWT token): ", open=False):
41
- output2 = gr.Textbox(placeholder="Attestation token", label="Output")
42
- gr.Markdown(value=token_info)
43
- trigger.click(fn=run_query, inputs=[server, prompt], outputs=[output, output2])
44
  gr.HTML(label="Contact", value="<img src='https://github.com/mithril-security/blindbox/blob/laura-images/docs/assets/contact-us.png?raw=true.png' alt='contact' style='display: block; margin: auto; max-width: 600px;'>")
45
  if __name__ == "__main__":
46
  demo.launch()
 
2
  from blindbox.requests import SecureSession
3
 
4
  DEMO_SERVER = "4.208.9.167:80"
5
+ text = "<h1 style='text-align: center; color: white;'>πŸŽ… SantaCoder with <span style='color: #f0ba2d;'>BlindBox:</span> Confidential Coding Assistant</h1><p style='text-align: left; color: white;'>This is a demo to show what Zero Trust LLM usage looks like for the use case of Confidential Coding Assistant.</p><p style='text-align: left; color: white;'>Here we can leverage a remotely hosted SantaCoder, a state-of-the-art code completion LLM, inside a secure enclave, which ensures code sent for completion is not exposed to anyone else, including us, thanks to end-to-end protection! Therefore LLMs can be leveraged easily to help boost productivity without worrying about IP exposure.</p><p style='text-align: left; color: white;'>To learn more about how data is secured, you can find out more in our <a style='color: #f0ba2d; href='https://blindbox.mithrilsecurity.io/en/latest/'>docs</a>.</p><p style='text-align: left; color: white;'>You can see how we deployed SantaCoder with an Azure Confidential VM by checking out the relevant <a style='color: #f0ba2d;', href='https://blindbox.mithrilsecurity.io/en/latest/docs/how-to-guides/santacoder/'>integration guide</a> in our docs.</p><p style='text-align: left; color: white;'>⚠️ <a style='color: #f0ba2d;', href='https://github.com/mithril-security/blindbox'/>BlindBox</a> is still under development. We have implemented attestation and deployment on Confidential VMs, but we recommend not to send production data on this demo yet.</p><p style='text-align: left; color: white;>If you are interested in pentesting, improving security or knowing more about Confidential LLMs, <a a style='color: #f0ba2d;', href='https://www.mithrilsecurity.io/contact'>reach out to us!</a></p>"
6
+ def run_query(prompt):
 
 
 
 
7
  POLICY = "./cce_policy.txt"
8
  if prompt == None:
9
+ return ("β›” Error: please provide input code")
10
  message = "\n\nβœ… Secure query succesful"
 
11
  try:
12
  with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
13
  res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
14
  cleaned = res.text.replace('\\n', '\n').split('\n\n')[0].split(':"')[1]
15
  cleaned = cleaned.replace('\\', '')
16
+ return(cleaned + message)
17
  except Exception as err:
18
  return(f"β›” Query failed!\n{err}")
19
 
20
  demo = gr.Blocks(css=".gradio-container { background-color: #20233fff;} .app.svelte-1mya07g.svelte-1mya07g {max-width: 900px !important;}")
21
  with demo:
22
  gr.Markdown(value=text)
 
23
  _, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
24
  with colum_2:
25
  prompt = gr.Code(lines=3, language="python", label="Input code", value="def hello_name(name):")
 
 
 
 
 
26
  trigger = gr.Button(label="Run query")
27
  with gr.Column():
28
  output = gr.Textbox(placeholder="Output", label="Output")
29
+ trigger.click(fn=run_query, inputs=[prompt], outputs=[output])
 
 
 
30
  gr.HTML(label="Contact", value="<img src='https://github.com/mithril-security/blindbox/blob/laura-images/docs/assets/contact-us.png?raw=true.png' alt='contact' style='display: block; margin: auto; max-width: 600px;'>")
31
  if __name__ == "__main__":
32
  demo.launch()