Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Nandini-13/PsycheIT/llms.txt

Use this file to discover all available pages before exploring further.

The /classify endpoint is the analytical core of PsycheIT. It accepts a raw, free-text message typed by a student and runs it through an in-memory Naive Bayes classifier trained on labelled mental health topics. The response tells the frontend which intent was detected with the highest confidence — enabling the chatbot to route conversations to the right support content, suggest coping strategies, or escalate to a human counselor.

Endpoint

POST /classify

Request Body

message
string
required
The student’s free-text message to be classified. Must be a non-empty string. Passing a missing field, null, or a non-string value returns a 400 error.

Response Fields

intent
string
The single top-ranked intent label predicted by the classifier. One of: greeting, academic, family, social, sleep, anxiety, highrisk, depression, general, counselor.
classifications
array
An ordered array of the top 3 classification objects, ranked by descending log-probability score.

Example Request

curl -X POST http://localhost:5000/classify \
  -H "Content-Type: application/json" \
  -d '{"message": "I feel anxious before my exams and can'\''t sleep"}'

Example Response

{
  "intent": "anxiety",
  "classifications": [
    { "label": "anxiety", "value": -3.456 },
    { "label": "academic", "value": -3.891 },
    { "label": "sleep", "value": -4.123 }
  ]
}

Intent Reference

The classifier recognises ten intent labels. The table below describes each intent and lists representative phrases that trigger it.
IntentDescriptionExample Phrases
greetingCasual openers and introductory messages”Hi”, “Hello”, “Hey there”, “Good morning”
academicStress, pressure, or struggles related to studies and exams”I’m failing my exams”, “Too much pressure from assignments”, “Grades are bad”
familyIssues arising from family relationships or home environment”My parents are fighting”, “I feel unsupported at home”, “Family stress”
socialLoneliness, peer relationships, bullying, or social isolation”I have no friends”, “People ignore me”, “I feel left out on campus”
sleepSleep disturbances, insomnia, or exhaustion”I can’t sleep”, “I keep waking up at night”, “I feel exhausted all the time”
anxietyWorry, panic, nervousness, or physical symptoms of anxiety”I feel anxious”, “My heart races”, “I’m constantly worried about everything”
highriskExpressions of self-harm, suicidal ideation, or crisis-level distress”I want to hurt myself”, “I don’t want to live”, “Everything feels hopeless”
depressionPersistent sadness, low mood, loss of interest, or hopelessness”I feel empty”, “Nothing makes me happy”, “I’ve lost motivation for everything”
generalVague or mixed emotional distress that doesn’t fit a specific category”I don’t feel okay”, “Something is wrong with me”, “I’m not doing well”
counselorExplicit requests to speak with or be referred to a counselor”I want to talk to someone”, “Can I speak to a counselor?”, “I need help”

Error Responses

StatusBodyCause
400{ "error": "missing message" }The message field is absent, null, or not a string.

How the Classifier Works

The Naive Bayes classifier is powered by natural.BayesClassifier from the natural NLP library. At server startup, labelled training documents covering all 10 intent categories are added to the classifier and train() is called once, building the model entirely in memory. There is no persistence — the model is retrained from scratch on every server restart. No student messages are stored or used to retrain the model.

Build docs developers (and LLMs) love