Sameer Gupta
Vidur Chatbot V1.1 β€” LangGraph pipeline
db9dd84
Raw
History Blame Contribute Delete
924 Bytes
"""
classify.py
───────────
classify node: route the user message into one of the wellness query categories
(conversational / intrinsic / external / personal / hybrid / analytical).
`classify_input` is the small-model classifier lifted from the old
`utils.classify_input`. The node also seeds `rag_context` to "NULL"; the retrieve
node overrides it when RAG actually runs.
"""
from __future__ import annotations
from app.graph.state import GraphState
from app.prompts import CLASSIFY_PROMPT
from app.services.llm import get_classifier_llm
def classify_input(user_input: str) -> str:
llm = get_classifier_llm()
response = llm.invoke(CLASSIFY_PROMPT.format(user_input=user_input))
return response.content.strip().lower()
def classify(state: GraphState) -> dict:
classification = classify_input(state["message"])
return {"classification": classification, "rag_context": "NULL"}