Spaces:
Sleeping
Sleeping
Download task_classifier.py from Sarupa/AI_Confidence_Layer: direct link, hf CLI and curl.
- Browser
- Download file 873 Bytes
-
https://huggingface.co/spaces/Sarupa/AI_Confidence_Layer/resolve/main/task_classifier.py
- Command line
-
hf download hf://spaces/Sarupa/AI_Confidence_Layer/task_classifier.py
-
curl -L -o task_classifier.py https://huggingface.co/spaces/Sarupa/AI_Confidence_Layer/resolve/main/task_classifier.py
873 Bytes
| def classify_prompt(prompt: str) -> str: | |
| """ | |
| Classify the prompt into one of three task types that require | |
| different confidence interpretation strategies. | |
| Returns: "creative" | "analytical" | "factual" | |
| """ | |
| p = prompt.lower() | |
| creative_words = [ | |
| "story", "poem", "imagine", "invent", "create", "write a", "generate a", | |
| "fiction", "narrative", "fantasy", "describe a scene", "compose" | |
| ] | |
| analytical_words = [ | |
| "explain", "why", "how", "should", "what causes", "what is the reason", | |
| "compare", "analyze", "analyse", "difference between", "pros and cons", | |
| "evaluate", "argue", "opinion", "think about" | |
| ] | |
| if any(word in p for word in creative_words): | |
| return "creative" | |
| elif any(word in p for word in analytical_words): | |
| return "analytical" | |
| else: | |
| return "factual" | |