lauro1 commited on
Commit
0603825
1 Parent(s): 7e462e2

just missing server address

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from blindbox.requests import SecureSession
3
+
4
+ DEMO_SERVER = ""
5
+
6
+ def run_query( prompt):
7
+ POLICY = "./cce_policy.txt"
8
+ try:
9
+ with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
10
+ res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
11
+ return("✅ Query successful\n" + res.text)
12
+ except Exception as err:
13
+ return(f"⛔ Query failed!\n")
14
+
15
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
16
+ gr.Markdown("<h1><center>🔒Confidential code generation with BlindBox and Santacoder</center></h1>")
17
+ 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>")
18
+ 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>")
19
+ with gr.Column():
20
+ prompt = gr.Textbox(lines=2, placeholder="Enter function definition here e.g. def print_name(name):")
21
+ with gr.Column():
22
+ trigger = gr.Button("Test query")
23
+ with gr.Column():
24
+ output = gr.Textbox(placeholder="Output", label="See the output of your query here")
25
+ trigger.click(fn=run_query, inputs=[prompt], outputs=output)
26
+
27
+ if __name__ == "__main__":
28
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ blindbox>=0.2.0
2
+