Spaces:
Runtime error
Runtime error
updated
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
from blindbox.requests import SecureSession
|
| 3 |
|
| 4 |
DEMO_SERVER = "4.208.9.167:80"
|
|
|
|
| 5 |
|
| 6 |
def run_query( server, prompt):
|
| 7 |
if server == "Non-confidential VM server":
|
|
@@ -9,22 +10,23 @@ def run_query( server, prompt):
|
|
| 9 |
POLICY = "./cce_policy.txt"
|
| 10 |
if prompt == None:
|
| 11 |
return ("β Error: please provide input code")
|
|
|
|
| 12 |
try:
|
| 13 |
with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
|
| 14 |
res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
|
| 15 |
cleaned = res.text.replace('\\n', '\n').split('\n\n')[0].split(':"')[1]
|
| 16 |
cleaned = cleaned.replace('\\', '')
|
| 17 |
-
return(cleaned +
|
| 18 |
except Exception as err:
|
| 19 |
return(f"β Query failed!\n{err}")
|
| 20 |
|
| 21 |
-
with gr.Blocks(css=".gradio-container {background-color: #20233fff}") as demo:
|
| 22 |
gr.Markdown("<h1 style='text-align: center; color: white;'>π
SantaCoder with <span style='color: #f0ba2d;'>BlindBox:</span> Private Code Generation </h1>")
|
| 23 |
-
|
| 24 |
-
gr.Markdown("<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/'>end-to-end protected.</a></p>")
|
| 25 |
gr.Markdown("<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>")
|
| 26 |
gr.Markdown("<p style='text-align: left; color: white;'>β οΈ BlindBox is still under development. Do not test with production data!</p>")
|
| 27 |
-
|
|
|
|
| 28 |
_, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
|
| 29 |
with colum_2:
|
| 30 |
prompt = gr.Code(lines=3, language="python", label="Input code", value="def hello_name(name):")
|
|
@@ -37,7 +39,6 @@ with gr.Blocks(css=".gradio-container {background-color: #20233fff}") as demo:
|
|
| 37 |
with gr.Column():
|
| 38 |
output = gr.Textbox(placeholder="Output", label="Output")
|
| 39 |
trigger.click(fn=run_query, inputs=[server, prompt], outputs=output)
|
| 40 |
-
gr.HTML(label="Contact", value="<img src='https://github.com/mithril-security/blindbox/blob/
|
| 41 |
-
|
| 42 |
if __name__ == "__main__":
|
| 43 |
demo.launch()
|
|
|
|
| 2 |
from blindbox.requests import SecureSession
|
| 3 |
|
| 4 |
DEMO_SERVER = "4.208.9.167:80"
|
| 5 |
+
bullets = "<ul><li style='color: white;'>β
Connection verified by attestation</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>"
|
| 6 |
|
| 7 |
def run_query( server, prompt):
|
| 8 |
if server == "Non-confidential VM server":
|
|
|
|
| 10 |
POLICY = "./cce_policy.txt"
|
| 11 |
if prompt == None:
|
| 12 |
return ("β Error: please provide input code")
|
| 13 |
+
message = "\n\nβ
Secure query succesful"
|
| 14 |
try:
|
| 15 |
with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
|
| 16 |
res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
|
| 17 |
cleaned = res.text.replace('\\n', '\n').split('\n\n')[0].split(':"')[1]
|
| 18 |
cleaned = cleaned.replace('\\', '')
|
| 19 |
+
return(cleaned + message)
|
| 20 |
except Exception as err:
|
| 21 |
return(f"β Query failed!\n{err}")
|
| 22 |
|
| 23 |
+
with gr.Blocks(css=".gradio-container {background-color: #20233fff;}") as demo:
|
| 24 |
gr.Markdown("<h1 style='text-align: center; color: white;'>π
SantaCoder with <span style='color: #f0ba2d;'>BlindBox:</span> Private Code Generation </h1>")
|
| 25 |
+
gr.Markdown("<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></p>")
|
|
|
|
| 26 |
gr.Markdown("<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>")
|
| 27 |
gr.Markdown("<p style='text-align: left; color: white;'>β οΈ BlindBox is still under development. Do not test with production data!</p>")
|
| 28 |
+
gr.Markdown(value=bullets)
|
| 29 |
+
|
| 30 |
_, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
|
| 31 |
with colum_2:
|
| 32 |
prompt = gr.Code(lines=3, language="python", label="Input code", value="def hello_name(name):")
|
|
|
|
| 39 |
with gr.Column():
|
| 40 |
output = gr.Textbox(placeholder="Output", label="Output")
|
| 41 |
trigger.click(fn=run_query, inputs=[server, prompt], outputs=output)
|
| 42 |
+
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;'>")
|
|
|
|
| 43 |
if __name__ == "__main__":
|
| 44 |
demo.launch()
|