| 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."} | |