Download handler.py from abdullahed/av-k.1: direct link, hf CLI and curl.
- Browser
- Download file 632 Bytes
-
https://huggingface.co/abdullahed/av-k.1/resolve/main/handler.py
- Command line
-
hf download hf://abdullahed/av-k.1/handler.py
-
curl -L -o handler.py https://huggingface.co/abdullahed/av-k.1/resolve/main/handler.py
632 Bytes
| from brain import AVK1Brain | |
| class EndpointHandler(): | |
| def __init__(self, path=""): | |
| self.brain = AVK1Brain() | |
| def __call__(self, data): | |
| """ | |
| Args: | |
| data (:obj: `dict`): | |
| data contains the inputs and parameters for inference. | |
| """ | |
| inputs = data.pop("inputs", data) | |
| parameters = data.pop("parameters", None) | |
| # Simple string input for chat | |
| if isinstance(inputs, str): | |
| result = self.brain.chat(inputs) | |
| return {"response": result} | |
| return {"error": "Invalid input format. Expected a string."} | |