Skip to content

[M5] LLMFrame: surface current context into Claude prompt with suggested actions #48

Description

@Korede-TA

Goal

A frame that assembles the user's current selection and corpus context into a structured prompt and offers a set of short, actionable suggested prompts — enabling the user to move from exploration to synthesis in one click.

Context assembly

The frame builds a context block from live store state:

  • Selected nodes: deriveLabel + full node.text (truncated at ~400 tokens total across all selected)
  • Temporal range: if a date filter or selection has a time span, include "Documents spanning [year] – [year]"
  • Geographic focus: top location names from selected nodes' geo annotations
  • Key entities: top person/org names from selected nodes' entity annotations
  • Current level + scope: e.g. "Viewing 23 chunks within document 'Lake Chad Report'"

Suggested prompts

Show 4–6 short prompt chips that are dynamically generated based on what's in context. Examples based on selection type:

  • Single document selected: "Summarize this document", "What are the key claims?", "List the locations mentioned"
  • Multiple chunks selected: "What themes connect these passages?", "Identify contradictions across these excerpts"
  • Geographic selection: "What events happened in [top location]?", "Describe the geographic pattern"
  • Temporal selection: "Summarize what changed between [year] and [year]"
  • Entity-heavy selection: "What is the role of [top entity] across these documents?"

Execution

  • Clicking a suggested prompt (or editing + submitting a custom one) sends the context + prompt to the Claude API via akb serve backend endpoint (POST /llm)
  • The akb serve endpoint calls anthropic.messages.create with the assembled context as a system block and the prompt as the user turn
  • Response streams back and is rendered in the frame as markdown
  • Response includes a "Copy" button and a "Save to notes" action (appends to a session notes store)

UI layout

  • Top section: read-only assembled context preview (collapsible, shows token count)
  • Middle: 4–6 suggested prompt chips (regenerate button)
  • Bottom: editable prompt textarea + Send button
  • Response area: streaming markdown output below

Registration

  • Register 'llm' in frame registry and add to ADDABLE_FRAMES
  • Backend: add POST /llm to akb serve (FastAPI, streams SSE)

Acceptance criteria

  • Suggested prompts update within 200ms of selection change
  • Prompt chips reflect the actual content of the selection (not generic defaults when context is available)
  • Response streams visibly (not a single delayed render)
  • Works offline in degraded mode: shows context + prompts but disables Send with "requires akb serve" message

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions