Download harness/adapters/generic.py from Daniel01410/microtensor_ctx_compress: direct link, hf CLI and curl.
- Browser
- Download file 681 Bytes
-
https://huggingface.co/Daniel01410/microtensor_ctx_compress/resolve/main/harness/adapters/generic.py
- Command line
-
hf download hf://Daniel01410/microtensor_ctx_compress/harness/adapters/generic.py
-
curl -L -o generic.py https://huggingface.co/Daniel01410/microtensor_ctx_compress/resolve/main/harness/adapters/generic.py
681 Bytes
| from __future__ import annotations | |
| from typing import Any | |
| from harness.adapters.base import Adapter, Verdict | |
| class GenericAdapter(Adapter): | |
| name = "generic" | |
| max_chars = 4000 | |
| def verify(self, text: str, task: dict[str, Any], tools_url: str) -> Verdict: | |
| answer = self.clean(text) | |
| if not answer: | |
| return Verdict(False, "", "empty answer") | |
| if len(answer) > self.max_chars: | |
| return Verdict(False, answer, f"answer longer than {self.max_chars} characters") | |
| if "ignore the task" in answer.lower(): | |
| return Verdict(False, answer, "answer repeats injected instructions") | |
| return Verdict(True, answer) | |