Skip to content

Enable live OpenRouter chat (location-aware news context) #19

Description

@ShahriarNewaz

Enable live OpenRouter chat (location-aware news context)

Summary

Chat currently runs in deterministic mock mode unless OPENROUTER_API_KEY is set and LLM_MOCK=false. We want chat to reliably use the user-selected location, fetch relevant news for that location, and produce live AI responses when configured.

Expected user behavior

  1. User selects a location (e.g., “Chattogram”).
  2. UI immediately shows a status like: Fetching news for Chattogram….
  3. Backend performs place-scoped ingest (without mutating watchlist) and updates events for that area.
  4. User sends a chat message (e.g., “Brief this place”).
  5. AI reply uses the selected place’s context/events/incidents.
  6. When live mode is active, the API response should indicate it is not mock (e.g., mock: false / no llm: mock).

Required configuration (keep secrets out of git)

  • Set OPENROUTER_API_KEY in the local .env (do not commit).
  • Set LLM_MOCK=false.
  • Set INGEST_MOCK=false when verifying live ingest.

Safety

  • Never present sample OSINT rows as official police reports.
  • Do not leak secrets or stack traces in errors or logs.

Acceptance criteria

  • With OPENROUTER_API_KEY set and LLM_MOCK=false, POST /api/chat returns a live response (not mock).
  • Selecting a place triggers place-scoped ingest and chat uses the selected location.
  • If ingest yields zero relevant events, chat returns a “no news found / limited context” caveat (not silent success).
  • Stale selections cannot overwrite newer ones (sequence/token guard).

Manual test (after enabling live mode)

  1. Put OPENROUTER_API_KEY=... in .env.
  2. Set LLM_MOCK=false and INGEST_MOCK=false.
  3. Start: .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions