-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_entry.py
More file actions
27 lines (18 loc) · 839 Bytes
/
main_entry.py
File metadata and controls
27 lines (18 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from fedml.serving import FedMLPredictor
from fedml.serving import FedMLInferenceRunner
class Bot(FedMLPredictor): # Inherit FedMLClientPredictor
def __init__(self):
super().__init__()
# --- Your model initialization code here ---
# -------------------------------------------
def predict(self, request: dict):
input_dict = request
question: str = input_dict.get("text", "").strip()
# --- Your model inference code here ---
response = "I do not know the answer to your question."
# ---------------------------------------
return {"generated_text": f"The answer to your question {question} is: {response}"}
if __name__ == "__main__":
chatbot = Bot()
fedml_inference_runner = FedMLInferenceRunner(chatbot)
fedml_inference_runner.run()