Update handler.py
Browse files- handler.py +8 -1
handler.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
|
| 3 |
class EndpointHandler:
|
| 4 |
def __init__(self, model_dir):
|
|
@@ -9,4 +10,10 @@ class EndpointHandler:
|
|
| 9 |
return
|
| 10 |
|
| 11 |
def predict(self, inputs):
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
+
from datetime import datetime
|
| 3 |
|
| 4 |
class EndpointHandler:
|
| 5 |
def __init__(self, model_dir):
|
|
|
|
| 10 |
return
|
| 11 |
|
| 12 |
def predict(self, inputs):
|
| 13 |
+
if not isinstance(inputs, dict) or "inputs" not in inputs:
|
| 14 |
+
return {"error": "Invalid input format. Expected {'inputs': 'your text'}"}
|
| 15 |
+
|
| 16 |
+
user_text = inputs["inputs"]
|
| 17 |
+
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 18 |
+
|
| 19 |
+
return {"message": f"Received at {current_time}: {user_text}"}
|