WenqingZhang commited on
Commit
182627d
·
verified ·
1 Parent(s): 6733f2d

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +13 -0
server.py CHANGED
@@ -25,6 +25,8 @@ def root():
25
 
26
  @app.post("/predict_sentiment")
27
  def predict_sentiment(query: PredictRequest):
 
 
28
  encrypted_encoding = base64.b64decode(query.encrypted_encoding)
29
  evaluation_key = base64.b64decode(query.evaluation_key)
30
  prediction = fhe_model.run(encrypted_encoding, evaluation_key)
@@ -32,4 +34,15 @@ def predict_sentiment(query: PredictRequest):
32
  # Encode base64 the prediction
33
  encoded_prediction = base64.b64encode(prediction).decode()
34
  return {"encrypted_prediction": encoded_prediction}
 
 
 
 
 
 
 
 
35
 
 
 
 
 
25
 
26
  @app.post("/predict_sentiment")
27
  def predict_sentiment(query: PredictRequest):
28
+ fhe_model = FHEModelServer("deployment/financial_rating")
29
+
30
  encrypted_encoding = base64.b64decode(query.encrypted_encoding)
31
  evaluation_key = base64.b64decode(query.evaluation_key)
32
  prediction = fhe_model.run(encrypted_encoding, evaluation_key)
 
34
  # Encode base64 the prediction
35
  encoded_prediction = base64.b64encode(prediction).decode()
36
  return {"encrypted_prediction": encoded_prediction}
37
+
38
+ @app.post("/predict_legal")
39
+ def predict_legal(query: PredictRequest):
40
+ fhe_legal_model = FHEModelServer("deployment/legal_rating")
41
+
42
+ encrypted_encoding = base64.b64decode(query.encrypted_encoding)
43
+ evaluation_key = base64.b64decode(query.evaluation_key)
44
+ prediction = fhe_legal_model.run(encrypted_encoding, evaluation_key)
45
 
46
+ # Encode base64 the prediction
47
+ encoded_prediction = base64.b64encode(prediction).decode()
48
+ return {"encrypted_prediction": encoded_prediction}