Spaces:
Running
Running
Download handler.py from projecte-aina/EADOP-RAG: direct link, hf CLI and curl.
- Browser
- Download file 491 Bytes
-
https://huggingface.co/spaces/projecte-aina/EADOP-RAG/resolve/main/handler.py
- Command line
-
hf download hf://spaces/projecte-aina/EADOP-RAG/handler.py
-
curl -L -o handler.py https://huggingface.co/spaces/projecte-aina/EADOP-RAG/resolve/main/handler.py
491 Bytes
| import json | |
| class ContentHandler(): | |
| content_type = "application/json" | |
| accepts = "application/json" | |
| def transform_input(self, prompt: str, model_kwargs: dict) -> bytes: | |
| input_str = json.dumps({'inputs': prompt, 'parameters': model_kwargs}) | |
| return input_str.encode('utf-8') | |
| def transform_output(self, output: bytes) -> str: | |
| response_json = json.loads(output.read().decode("utf-8")) | |
| return response_json[0]["generated_text"] | |