Update handler.py
Browse files- handler.py +16 -21
handler.py
CHANGED
|
@@ -65,26 +65,21 @@ class EndpointHandler:
|
|
| 65 |
# 4. Return coordinates and their corresponding sensitivity scores
|
| 66 |
return [{"coord": idx, "score": score} for idx, score in zip(indices, distances)]
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
method = data.get("method", "embed")
|
| 77 |
-
logger.info("inputs: ")
|
| 78 |
-
logger.info(inputs)
|
| 79 |
-
logger.info(method)
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
return embedding.cpu().tolist()[0]
|
|
|
|
| 65 |
# 4. Return coordinates and their corresponding sensitivity scores
|
| 66 |
return [{"coord": idx, "score": score} for idx, score in zip(indices, distances)]
|
| 67 |
|
| 68 |
+
def __call__(self, data):
|
| 69 |
+
inputs = data.get("inputs", "")
|
| 70 |
+
method = data.get("method", "embed")
|
| 71 |
+
|
| 72 |
+
# Extract parameters with sensible defaults
|
| 73 |
+
# This allows your LangGraph agent to "tune" the resolution
|
| 74 |
+
window_size = data.get("window_size", 50)
|
| 75 |
+
step = data.get("step", 100)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
if not inputs:
|
| 78 |
+
return {"error": "No input sequence provided"}
|
| 79 |
|
| 80 |
+
if method == "sensitivity":
|
| 81 |
+
# Pass the new parameters into the mapper
|
| 82 |
+
return self.map_sensitivity(inputs, window_size=window_size, step=step)
|
| 83 |
+
else:
|
| 84 |
+
embedding = self._get_embedding(inputs)
|
| 85 |
+
return embedding.cpu().tolist()[0]
|
|
|