Download ASP/reference_version.py from mahendra0120/Agentic_Serial-killer_Profiler: direct link, hf CLI and curl.
- Browser
- Download file 2.1 kB
-
https://huggingface.co/mahendra0120/Agentic_Serial-killer_Profiler/resolve/refs%2Fpr%2F1/ASP/reference_version.py
- Command line
-
hf download hf://mahendra0120/Agentic_Serial-killer_Profiler@refs/pr/1/ASP/reference_version.py
-
curl -L -o reference_version.py https://huggingface.co/mahendra0120/Agentic_Serial-killer_Profiler/resolve/refs%2Fpr%2F1/ASP/reference_version.py
2.1 kB
| import re | |
| from typing import Iterable, Optional | |
| AUTO = "auto" | |
| BASIC = "basic" | |
| ADVANCED = "advanced" | |
| VERSIONS = (AUTO, BASIC, ADVANCED) | |
| CHOICES = [ | |
| ("Auto: the model decides whether to use the Basic or Advanced pages", AUTO), | |
| ("Basic: the 5 reference pages only", BASIC), | |
| ("Advanced: also consult the Advanced pages", ADVANCED), | |
| ] | |
| MARKER = re.compile(r"\[\[asp:reference-version=(basic|advanced)\]\]") | |
| DIRECTIVES = { | |
| BASIC: ( | |
| "[[asp:reference-version=basic]]\n" | |
| "Reference version selected by the user: BASIC. Use only the 5 reference images already " | |
| "attached to this conversation. The image viewer tools are disabled for this run." | |
| ), | |
| ADVANCED: ( | |
| "[[asp:reference-version=advanced]]\n" | |
| "Reference version selected by the user: ADVANCED. In addition to the 5 attached reference " | |
| "images, you MUST consult the Advanced pages before writing your profile: call list_sections, " | |
| "then view_section for the sections relevant to this case, and use what you see in your analysis." | |
| ), | |
| } | |
| def normalize(version) -> str: | |
| return version if version in VERSIONS else AUTO | |
| def label(version) -> str: | |
| names = {value: text.split(" - ")[0] for text, value in CHOICES} | |
| return names[normalize(version)] | |
| def directive(version) -> Optional[str]: | |
| return DIRECTIVES.get(normalize(version)) | |
| def texts_of(content) -> Iterable[str]: | |
| if isinstance(content, str): | |
| yield content | |
| elif isinstance(content, (list, tuple)): | |
| for item in content: | |
| if isinstance(item, str): | |
| yield item | |
| def version_from_messages(messages) -> str: | |
| for message in reversed(list(messages)): | |
| for part in getattr(message, "parts", ()): | |
| if getattr(part, "part_kind", None) != "user-prompt": | |
| continue | |
| for text in texts_of(getattr(part, "content", None)): | |
| found = MARKER.search(text) | |
| if found: | |
| return found.group(1) | |
| return AUTO | |