Spaces:
Runtime error
Runtime error
updated version feedback
Browse files
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>
|
6 |
-
|
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 (
|
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
|
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 |
-
|
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()
|