Skip to content

[Phase 4] Grounded teaching with citations UX #46

Description

@ahmedfahim21

Part of the Learnify 2.0 rebuild. Depends on #41, #45.

Context

Grounded sessions cite their sources. The Citations API is available on Bedrock: PDFs cite page numbers, custom-content chunks cite block indices, streamed via citations_delta. cited_text costs no output tokens. (Citations are incompatible with structured outputs — fine: widgets are emitted via tools, and concept-graph decomposition is a separate call.)

Tasks

  • Grounded prompt assembly: source chunks as citation-enabled document blocks (citations: {enabled: true}) with cache_control — PDFs as base64 document blocks, URL/YouTube as custom-content blocks
  • Handle citations_delta in the agent loop → citation markers streamed onto Narration
  • Widget-level cite: {sourceId, quote} props validated server-side by substring match against source_chunks (drop invalid cites)
  • Citation chips UI on Narration/ExplanationCard; click → source panel scrolls to the quoted chunk (PDF: page number, YouTube: timestamp)
  • System-prompt grounding rules: when sources attached, factual claims must come from them
  • Ungrounded topics keep working unchanged

Acceptance criteria

  • Attach a YouTube lecture + a PDF → explanations carry citation chips; chip click jumps to the exact quote
  • Detach sources → session runs ungrounded

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