Posts
AI analysis of results — mood from rules, text from the model
A language model should not score a mood journal on its own. It gets the numbers already computed — no notes — and puts them in plain language. If it does not answer, the rule-based evaluation stays.
If you hand a model a raw journal and ask it to “analyse,” you usually get one of three things: a platitude (“take care of yourself”), a diagnosis nobody asked for, or a sentence that sounds smart and disagrees with the numbers — for example “a stable stretch,” while the average dropped a point. A better prompt on the raw entries does not fix that. The model simply does not know which part of the data is a fact and which part is something it made up.
For mood analysis in MoodJournal I split that into two layers. Rules compute the score. The model — if it is on at all — only narrates it. The same split makes sense anywhere a product promises an evaluation, not a chat.
What someone actually wants when they open the analysis
Not a table of averages. Three answers:
- whether things are better or worse than before,
- what is pulling the result down or up,
- what can change soon — in concrete terms.
Rules cover all of that without a model: a window of recent weeks, a trend, the spread, strong and weak areas, a few dry tips. The result is dull and the same every time — and that is the point. You can test it and demo it without an API key.
What the model does in that setup
It receives the picture that is already computed and turns it into a short text: a headline up to 80 characters, a paragraph up to 220, at most three tips. Written the way a person would say it, not like a string from a translation file.
Check-in notes never go to the model — only aggregates: trend, average, volatility, areas, tips. For a mood journal that matters more than a nicer paragraph. The instruction is explicit: stick to that JSON only, and do not give medical advice. Temperature: 0.4. Response language comes from the user’s settings.
The model does not guess that finances are weak — it gets that in the numbers. It has to say how that sounds and what to do about it. When the numbers say decline, the text should not describe a “calm, stable stretch.” The code just does not enforce that yet.
Where the model actually adds something the rules do not:
It folds several signals into one sentence. A rising trend, a wide spread, and one area in a trough are three separate fields for the rules. For a person — one story.
It picks a tone. The same facts can read like a report or like support. For mood, coaching, or feedback, tone is often half the reason anyone opens that screen.
It writes in the user’s language. Not “translate the button label” — the whole analysis in Polish has to sound Polish, including how directly you address the reader.
It chooses tips. Rules can emit five. Two that fit this week are worth more than the full list.
Below is a shortened input — what the model actually gets — and a reply that stays on it. An example of the contract shape, not a production dump.
{
"trend": "declining",
"averageOverall": 3.4,
"volatility": "high",
"entryCount": 8,
"windowDays": 30,
"aspectInsights": [
{ "aspect": "finances", "average": 2.1, "status": "focus" }
]
}
{
"headline": "The last few weeks are weaker, mostly because of money",
"detail": "The average dropped and the swings are wide. The other areas are not pulling the result the way finances are.",
"tips": [
"Pick one steady money habit for this week."
]
}
Where it falls apart
The model invents an average that was never in the data. Three entries become a life verdict. It gives a tip that fits everyone and no one. It praises “great balance” while the rules are pointing at finances as the problem. That text still gets through — I only check that a JSON headline, paragraph, or tip arrived. I do not check that it agrees with the trend.
A missing answer is a separate case. An error, a timeout, or an empty body leaves the rule-based analysis alone. The timeout is 20 seconds, so in the worst case that is how long someone waits before they see the result without the model. It is not an instant switch, and it is not a spinner that runs forever.
The fallback itself does not lie and does not disappear. A text that lies inside valid JSON still gets through. More on that below.
What I have not checked yet
I do not know how often the generated text contradicts the tips from the rules — someone would have to read it, or compare it automatically. I do not know whether the short line at the top helps anyone, or only looks tidy in the API response. I have not compared yet how a small local model tells the same data picture versus a cloud model. I also do not have a hard rule for when to show that “AI wrote this,” and when it is better to stay with the numbers alone.
The numbers stay with the rules. The model gets them only to narrate, without the notes. If there is no model, the evaluation is still there. MoodJournal is one place I built it this way — but the same idea travels anywhere an “AI analysis” is supposed to say something, not just generate a paragraph.