Spaces:
Runtime error
Runtime error
added attestation stuff
Browse files- app.py +32 -6
- hello_world.txt +1 -0
app.py
CHANGED
@@ -3,10 +3,19 @@ from blindbox.requests import SecureSession
|
|
3 |
|
4 |
DEMO_SERVER = "4.208.9.167:80"
|
5 |
|
6 |
-
def run_query( prompt):
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
try:
|
11 |
with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
|
12 |
res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
|
@@ -20,13 +29,30 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
20 |
gr.Markdown("<p>This is the demo for our article on deploying code generation LLM models with BlindBox: <b>AI-assisted code generation with privacy guarantees: Securely deploy SantaCoder with BlindBox</b><br>You can view the article <a href='ai-assisted-code-generation-with-privacy-guarantees-securely-deploy-santacoder-with-blindbox'>here!</a> </p>")
|
21 |
gr.Markdown("<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>")
|
22 |
gr.Markdown("<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>")
|
|
|
|
|
23 |
with gr.Column():
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
with gr.Column():
|
26 |
trigger = gr.Button("Test query")
|
27 |
with gr.Column():
|
28 |
output = gr.Textbox(placeholder="Output", label="See the output of your query here")
|
29 |
-
trigger.click(fn=run_query, inputs=[prompt], outputs=output)
|
30 |
|
31 |
if __name__ == "__main__":
|
32 |
demo.launch()
|
|
|
3 |
|
4 |
DEMO_SERVER = "4.208.9.167:80"
|
5 |
|
6 |
+
def run_query( server, policy, prompt):
|
7 |
+
if prompt == None or server == None or policy == None:
|
8 |
+
return("β Error: please select an option for stages 1-3")
|
9 |
+
if len(prompt) == 0 or len(policy) == 0 or len(server) == 0:
|
10 |
+
return("β Error: please select an option for stages 1-3")
|
11 |
+
if server != "Authentic confidential VM server":
|
12 |
+
return ("β Error: you can only connect to an application running on a Confidential VM")
|
13 |
+
if policy == "Expected Santacoder app policy file":
|
14 |
+
POLICY = "./cce_policy.txt"
|
15 |
+
elif policy == "Unexpected Hello World app policy file":
|
16 |
+
POLICY = "./hello_world.txt"
|
17 |
+
else:
|
18 |
+
POLICY = "fake.txt"
|
19 |
try:
|
20 |
with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
|
21 |
res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
|
|
|
29 |
gr.Markdown("<p>This is the demo for our article on deploying code generation LLM models with BlindBox: <b>AI-assisted code generation with privacy guarantees: Securely deploy SantaCoder with BlindBox</b><br>You can view the article <a href='ai-assisted-code-generation-with-privacy-guarantees-securely-deploy-santacoder-with-blindbox'>here!</a> </p>")
|
30 |
gr.Markdown("<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>")
|
31 |
gr.Markdown("<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>")
|
32 |
+
gr.Markdown("><h3>Step 1: Check we are connecting to an authentic confidential VM")
|
33 |
+
gr.Markdown("<p>This first option allows you to choose whether to connect to the Whisper application deployed with BlindBox on a confidential VM or the same application deployed on a dummy server which is not within a confidential VM!<br>This demonstrates how BlindBox blocks requests to non-authentic confidential VMs!</p>")
|
34 |
with gr.Column():
|
35 |
+
server = gr.Radio(
|
36 |
+
["Authentic confidential VM server", "Unauthentic dummy server"], label="Select the server you want to connect to"
|
37 |
+
)
|
38 |
+
gr.Markdown("><h3>Step 2: Check we are connecting to the latest official SaaS application image</h3>")
|
39 |
+
gr.Markdown("<p>You can think of this second verification a bit like a checksum. Here, you can see what happens if the end user queries the application whilst providing the latest policy file for our Santacoder application, the latest policy file for a different Hello World application or sends no policy file at all.<br></p>")
|
40 |
+
with gr.Column():
|
41 |
+
policy = gr.Radio(
|
42 |
+
["Expected Santacoder app policy file", "Unexpected Hello World app policy file", "No policy file"], label="Select your CCE policy file"
|
43 |
+
)
|
44 |
+
gr.Markdown("><h3>Step 3: Select your prompt</h3>")
|
45 |
+
gr.Markdown("<p>Select between the following prompt examples we provide.</p>")
|
46 |
+
with gr.Column():
|
47 |
+
prompt = gr.Radio(
|
48 |
+
["def sum(x, y):", "def print_name(name):", "def hello_world():", "def square_root(nbr):"], label="Select your user prompt"
|
49 |
+
)
|
50 |
+
gr.Markdown("><h3>Query the Santacoder model</h3>")
|
51 |
with gr.Column():
|
52 |
trigger = gr.Button("Test query")
|
53 |
with gr.Column():
|
54 |
output = gr.Textbox(placeholder="Output", label="See the output of your query here")
|
55 |
+
trigger.click(fn=run_query, inputs=[server, policy, prompt], outputs=output)
|
56 |
|
57 |
if __name__ == "__main__":
|
58 |
demo.launch()
|
hello_world.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
cGFja2FnZSBwb2xpY3kKCmltcG9ydCBmdXR1cmUua2V5d29yZHMuZXZlcnkKaW1wb3J0IGZ1dHVyZS5rZXl3b3Jkcy5pbgoKYXBpX3N2biA6PSAiMC4xMC4wIgpmcmFtZXdvcmtfc3ZuIDo9ICIwLjEuMCIKCmZyYWdtZW50cyA6PSBbCiAgewogICAgImZlZWQiOiAibWNyLm1pY3Jvc29mdC5jb20vYWNpL2FjaS1jYy1pbmZyYS1mcmFnbWVudCIsCiAgICAiaW5jbHVkZXMiOiBbCiAgICAgICJjb250YWluZXJzIgogICAgXSwKICAgICJpc3N1ZXIiOiAiZGlkOng1MDk6MDpzaGEyNTY6SV9faXVMMjVvWEVWRmRUUF9hQkx4X2VUMVJQSGJDUV9FQ0JRZllacHQ5czo6ZWt1OjEuMy42LjEuNC4xLjMxMS43Ni41OS4xLjMiLAogICAgIm1pbmltdW1fc3ZuIjogIjEuMC4wIgogIH0KXQoKY29udGFpbmVycyA6PSBbeyJhbGxvd19lbGV2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