Foresight.Prompts.Consolidation.V1 (Foresight v0.1.0)

Copy Markdown View Source

Faithful Elixir port of Hindsight's engine/consolidation/prompts.py (build_batch_consolidation_prompt): the LLM merge contract that turns raw facts into consolidated observations via creates/updates/deletes.

The MISSION defines what to track (bank-overridable) and takes priority over the PROCESSING RULES when the two conflict. Rules, decision guide, and output format are always present.

Summary

Functions

Render new facts as bracketed lines: [uuid] content (occurred_start=..., mentioned_at=...). Mirrors the Hindsight fact rendering the source_fact_ids rules refer to.

Render pooled existing observations as a JSON array string (empty → "[]").

Build the system + user messages for a batch consolidation call.

JSON schema for the creates/updates/deletes response contract.

Functions

format_facts(units)

@spec format_facts([map()]) :: String.t()

Render new facts as bracketed lines: [uuid] content (occurred_start=..., mentioned_at=...). Mirrors the Hindsight fact rendering the source_fact_ids rules refer to.

format_observations(observations)

@spec format_observations([map()]) :: String.t()

Render pooled existing observations as a JSON array string (empty → "[]").

messages(mission, facts_text, observations_text, capacity_note \\ nil)

@spec messages(String.t() | nil, String.t(), String.t(), String.t() | nil) :: [map()]

Build the system + user messages for a batch consolidation call.

mission is the bank's observations mission (nil → default). facts_text and observations_text are the rendered INPUT sections (see format_facts/1 and format_observations/1). capacity_note is an optional slot-cap constraint.

schema()

@spec schema() :: map()

JSON schema for the creates/updates/deletes response contract.