Skip to content

PDF Viewer Component for Sustainability Reports #68

Description

@suung

Background

We want to not only provide an end-to-end analysis but also support analysts in the process of reading through the report and verifying the answers.

Goals

Analysts can can see the report and navigate through it

Acceptance Criteria

Implementation

PDF Component in #21 depents on #13

We want to have the PDF component from main and then merge json schema component later

  • Make a new branch from main
  • Cherry-pick or move all relevant files from pdf-component into that new branch

PDF Viewer — BDD acceptance criteria

Feature: Verify analysis against the source PDF

  • Scenario: Analyst opens the PDF viewer after analysis
    Given an analysis has completed for a report PDF with chunk results
    When the analyst expands the PDF viewer section
    Then the source PDF is shown next to the related chunks for that analysis

  • Scenario: Analyst focuses on one question
    Given the PDF viewer is open with results for multiple questions
    When the analyst selects a single question
    Then only chunks for that question are listed and highlighted on the PDF

  • Scenario: Analyst views all questions again
    Given the PDF viewer is filtered to one question
    When the analyst selects all questions
    Then chunks for every question in the analysis are available again

  • Scenario: Analyst filters to evidence only
    Given retrieved and evidence chunks are shown for the current question scope
    When the analyst turns on evidence-only
    Then only chunks the model actually used as evidence remain visible and highlighted

  • Scenario: Analyst turns evidence-only off
    Given evidence-only is on
    When the analyst turns evidence-only off
    Then retrieved chunks that were not cited as evidence are visible again

  • Scenario: Analyst jumps from a chunk to the page
    Given a chunk is listed with a known page in the source PDF
    When the analyst selects that chunk
    Then the viewer navigates to that page and shows the matching highlight

  • Scenario: Analyst inspects a highlight
    Given a chunk highlight is visible on the PDF page
    When the analyst hovers that highlight
    Then they can see the scores and order needed to judge the citation

  • Scenario: Analyst moves between pages
    Given a multi-page PDF is loaded in the viewer
    When the analyst goes to the next or previous page
    Then the displayed page updates and the page indicator reflects the current position

  • Scenario: No chunks match the current filters
    Given the current question and evidence filters match no chunks
    When the viewer updates
    Then the analyst is told there are no chunks to display instead of seeing a broken empty pane

  • Scenario: PDF cannot be loaded
    Given the report PDF path or data is unavailable
    When the viewer tries to load the document
    Then the analyst sees a clear loading failure rather than a silent blank viewer

Wireframe

Image

┌─ Streamlit: Analysis results ─────────────────────────────────────────┐ │ … answers / tables … │ │ │ │ ▾ 📄 PDF Viewer with Chunks │ │ ┌─ pdf-viewer-with-chunks ─────────────────────────────────────────┐ │ │ │ │ │ │ │ ┌─ SIDEBAR ─────────────┐ ┌─ VIEWER ─────────────────────────┐ │ │ │ │ │ Chunks by Question │ │ [Previous] Page 12 of 84 [Next] │ │ │ │ │ │ │ │ │ │ │ │ │ │ [ Question ▾ ] │ │ ┌────────────────────────────┐ │ │ │ │ │ │ All Questions │ │ │ │ │ │ │ │ │ │ Q1 How does org… │ │ │ PDF page (PDF.js) │ │ │ │ │ │ │ Q2 What targets… │ │ │ │ │ │ │ │ │ │ │ │ │ ▓▓▓ retrieved highlight │ │ │ │ │ │ │ ☐ Show evidence only │ │ │ ███ evidence highlight │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌─ chunk card ──────┐ │ │ │ (hover → tooltip) │ │ │ │ │ │ │ │ Chunk 3 [Evidence]│ │ │ │ sim / llm / chunk_order │ │ │ │ │ │ │ │ [Page 12] │ │ │ │ │ │ │ │ │ │ │ │ "…preview text…" │ │ │ └────────────────────────────┘ │ │ │ │ │ │ │ Sim: 0.850 LLM:… │ │ │ │ │ │ │ │ │ └────────────────────┘ │ │ │ │ │ │ │ │ ┌─ chunk card ──────┐ │ │ │ │ │ │ │ │ │ Chunk 7 [Page 14] │ │ │ │ │ │ │ │ │ │ (retrieved only) │ │ │ │ │ │ │ │ │ └────────────────────┘ │ │ │ │ │ │ │ └───────────────────────┘ └──────────────────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────┘ │ └───────────────────────────────────────────────────────────────────────┘

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions