Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
@@ -10,7 +10,7 @@ current_dir = Path(__file__).parent
|
|
10 |
|
11 |
# Load the model
|
12 |
fhe_model = FHEModelServer("deployment/financial_rating")
|
13 |
-
|
14 |
class PredictRequest(BaseModel):
|
15 |
evaluation_key: str
|
16 |
encrypted_encoding: str
|
@@ -29,6 +29,16 @@ def predict_sentiment(query: PredictRequest):
|
|
29 |
evaluation_key = base64.b64decode(query.evaluation_key)
|
30 |
prediction = fhe_model.run(encrypted_encoding, evaluation_key)
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# Encode base64 the prediction
|
33 |
encoded_prediction = base64.b64encode(prediction).decode()
|
34 |
return {"encrypted_prediction": encoded_prediction}
|
|
|
10 |
|
11 |
# Load the model
|
12 |
fhe_model = FHEModelServer("deployment/financial_rating")
|
13 |
+
fhe_legal_model = FHEModelServer("deployment/legal_rating")
|
14 |
class PredictRequest(BaseModel):
|
15 |
evaluation_key: str
|
16 |
encrypted_encoding: str
|
|
|
29 |
evaluation_key = base64.b64decode(query.evaluation_key)
|
30 |
prediction = fhe_model.run(encrypted_encoding, evaluation_key)
|
31 |
|
32 |
+
# Encode base64 the prediction
|
33 |
+
encoded_prediction = base64.b64encode(prediction).decode()
|
34 |
+
return {"encrypted_prediction": encoded_prediction}
|
35 |
+
|
36 |
+
@app.post("/predict_legal")
|
37 |
+
def predict_sentiment(query: PredictRequest):
|
38 |
+
encrypted_encoding = base64.b64decode(query.encrypted_encoding)
|
39 |
+
evaluation_key = base64.b64decode(query.evaluation_key)
|
40 |
+
prediction = fhe_legal_model.run(encrypted_encoding, evaluation_key)
|
41 |
+
|
42 |
# Encode base64 the prediction
|
43 |
encoded_prediction = base64.b64encode(prediction).decode()
|
44 |
return {"encrypted_prediction": encoded_prediction}
|