[Feature]: Surface source document + date as citations under AI chat answers

Author: just-jbcCreated Jul 31, 2026Updated Sep 13, 2026
Labelsenhancementreleased on @rc

Feature Category

Knowledge Base/RAG Improvement

Problem Statement

When NOMAD's AI answers a question using retrieved knowledge-base context, the answer gives no indication of which document backed it or how current that information is. For an offline tool meant to be relied on without internet access to cross-check anything, that's a real gap — especially for time-sensitive or safety-relevant content (e.g. the drug reference), where staleness and provenance matter.

Proposed Solution

Surface a deduplicated "Sources" list (title + date) under AI answers. ZIM-derived chunks already carry archive_date/archive_title in their Qdrant payload at ingestion time, but searchSimilarDocuments()'s returned metadata currently only maps article_title/full_title/section_title — the date fields exist in storage but aren't surfaced. This adds them to that mapping so both the internal context label and a new structured sources array can use them, adds a nullable sources column to chat_messages (small migration) threaded through addMessage() so sources persist with the message and still show when reopening a past conversation, and renders the list under assistant messages in the chat UI.

Alternative Solutions

Inline numbered citations ([1], [2] in the answer text) were considered and rejected for v1 — relies on the model reliably emitting correctly-attributed markers, which isn't guaranteed and risks misattributing a claim to the wrong source.

Use Case

As a NOMAD user, when the AI answers a question using knowledge-base context, I want to see which document it came from and how current that information is, so that I can judge how much to trust the answer before relying on it — especially for time-sensitive or safety-relevant content like the drug reference.

Who would benefit from this feature?

All Users

How important is this feature to you?

Medium - Would be nice to have

Implementation Ideas (Optional)

  • Add archive_date and archive_title (already stored in the Qdrant payload at ingestion, rag_service.ts) to the metadata object returned by searchSimilarDocuments(), which currently omits them.
  • Build a deduplicated sources array (title, date, filename) from the retrieved chunks in ollama_controller.ts's chat method, alongside the existing context-label logic.
  • Add a nullable sources column to chat_messages via migration; extend ChatService.addMessage() to accept and store it.
  • Return sources in both the streaming and non-streaming chat response shapes.
  • Frontend: render a small "Sources" list under assistant messages when present.

Examples or References

Similar in spirit to how AI search tools (e.g. Perplexity) show source citations under generated answers, adapted here for NOMAD's offline knowledge base.

Would you be willing to help implement this?

Yes - I can write the code

Additional Context

Non-ZIM sources (plain PDFs) don't carry embedded date/author metadata the way ZIM archives do, so citations for those will show title/filename only, no date — an inherent data limitation, not a bug in this feature.

Pre-submission Checklist

  • I have searched for existing feature requests that might be similar
  • This feature aligns with N.O.M.A.D.'s mission of offline-first knowledge and education
  • I understand that feature requests are not guaranteed to be implemented

Source: Crosstalk-Solutions/project-nomad