File size: 1,500 Bytes
63bcd5a 4552666 63bcd5a 4552666 63bcd5a 4552666 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | from src.recommendation_engine.llm_client import generate_text
VALID_INTENTS = {
"idea",
"feature",
"full_project",
"chat"
}
def detect_intent_semantic(user_input: str, state: dict) -> str:
prompt = f"""
You are an intent classifier for a graduation project assistant.
Classify the user intent into ONE of these:
idea
feature
description
full_project
chat
================ CONTEXT =================
Current Project Title:
{state.get("project_title") or "None"}
Has Features:
{"yes" if state.get("features") else "no"}
Has Description:
{"yes" if state.get("description") else "no"}
================ USER =================
"{user_input}"
================ RULES =================
- Asking for project ideas β idea
- Asking for another/new idea β idea
- Providing a project idea β feature
- Asking for features β featuregenerate features
- Asking for full project / full details β full_project
- If unclear β chat
IMPORTANT:
Return ONLY ONE WORD from the list.
"""
result = generate_text(prompt, task="intent").lower().strip()
result = result.split()[0].strip()
if result in VALID_INTENTS:
return result
text = user_input.lower()
if any(w in text for w in ["idea", "project", "suggest"]):
return "idea"
if any(w in text for w in ["feature"]):
return "feature"
if any(w in text for w in ["full", "all details", "complete"]):
return "full_project"
return "chat"
|