Spaces:
Sleeping
Sleeping
Download intent_classifier.py from RoxieRoller/H-script-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/RoxieRoller/H-script-AI/resolve/main/intent_classifier.py
- Command line
-
hf download hf://spaces/RoxieRoller/H-script-AI/intent_classifier.py
-
curl -L -o intent_classifier.py https://huggingface.co/spaces/RoxieRoller/H-script-AI/resolve/main/intent_classifier.py
1.01 kB
| # intent_classifier.py — NLP Intent Detection | |
| # Implemented: intent classification via LLM (Groq/Llama) in api/agent.py | |
| # The agent endpoint classifies intent from conversation context automatically. | |
| def classify_intent(prompt: str) -> str: | |
| """ | |
| Returns one of: generate | debug | explain | review | refactor | chat | |
| Note: In production this is handled by the Groq agent via TOOL_CALL parsing. | |
| This helper uses keyword matching as a fast local fallback. | |
| """ | |
| p = prompt.lower() | |
| if any(k in p for k in ["generate", "write", "create", "make"]): | |
| return "generate" | |
| if any(k in p for k in ["fix", "debug", "broken", "error", "wrong"]): | |
| return "debug" | |
| if any(k in p for k in ["explain", "what does", "how does", "samjhao"]): | |
| return "explain" | |
| if any(k in p for k in ["review", "check", "feedback", "improve"]): | |
| return "review" | |
| if any(k in p for k in ["refactor", "clean", "optimise", "optimize"]): | |
| return "refactor" | |
| return "chat" | |