Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DB_PASSWORD=postgres
# AI Insights — Gemini-powered recommendations
# Insights are disabled if GOOGLE_API_KEY is unset (rest of the API still runs).
GOOGLE_API_KEY=your_google_ai_studio_key_here
GEMINI_MODEL=gemini-1.5-flash
GEMINI_MODEL=gemini-2.5-flash
INSIGHTS_ENABLED=true
INSIGHT_CHECK_INTERVAL_SECONDS=600
INSIGHT_COOLDOWN_MINUTES=45
Expand Down
4 changes: 2 additions & 2 deletions docs/ai-insights.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Gemini-powered pipeline that watches each user's metrics and surfaces concrete

1. The **insight scheduler** ticks every `INSIGHT_CHECK_INTERVAL_SECONDS` (default 600 s).
2. For each user with telemetry in the last `INSIGHT_ACTIVITY_WINDOW_MINUTES` (default 30), the **rule engine** evaluates today's metrics + current session.
3. If a rule fires AND the user is not in cooldown, the system asks **Gemini** (`gemini-1.5-flash` by default) to characterize the workflow state and propose one action.
3. If a rule fires AND the user is not in cooldown, the system asks **Gemini** (`gemini-2.5-flash` by default) to characterize the workflow state and propose one action.
4. Gemini returns strict JSON validated against an enum schema. Invalid responses are dropped, never persisted.
5. A `WorkflowState` row + a `Recommendation` row are written. Any prior pending recommendation for the user is marked `expired` in the same transaction.

Expand Down Expand Up @@ -63,7 +63,7 @@ All require JWT or `dvf_` API token auth. The action endpoint also verifies owne
| Variable | Default | Purpose |
| --- | --- | --- |
| `GOOGLE_API_KEY` | _(unset)_ | Required to enable the pipeline. Unset = scheduler logs a single warning at boot and disables itself; rest of the API works. |
| `GEMINI_MODEL` | `gemini-1.5-flash` | Model name passed to the SDK. |
| `GEMINI_MODEL` | `gemini-2.5-flash` | Model name passed to the SDK. |
| `INSIGHTS_ENABLED` | `true` | Kill switch. Set to `false` to disable the scheduler. |
| `INSIGHT_CHECK_INTERVAL_SECONDS` | `600` | How often the scheduler ticks. |
| `INSIGHT_COOLDOWN_MINUTES` | `45` | Minimum gap between recommendations for the same user. |
Expand Down
2 changes: 1 addition & 1 deletion src/services/llm/gemini.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ajv = new Ajv();
const validateInsight = ajv.compile(insightSchema);

const apiKey = process.env.GOOGLE_API_KEY;
const modelName = process.env.GEMINI_MODEL || 'gemini-1.5-flash';
const modelName = process.env.GEMINI_MODEL || 'gemini-2.5-flash';

let model = null;
if (apiKey) {
Expand Down
Loading