ExAgent.Message.Citation (ExAgent v3.0.0)

View Source

A source cited by a model response.

Stability — Candidate.

The source is an HTTP(S) URL, an attachment ID, or a document ID or zero-based document index. It carries no attachment bytes. quote is an optional excerpt from the source. source_range locates it in the source when the provider supplies coordinates. answer_range locates the citation in ExAgent.Message.Response.text/1 using zero-based, half-open UTF-8 byte offsets.

Source identifiers are limited to 2,048 bytes, titles to 256 bytes and quotes to 1,024 bytes. A response can hold up to 32 citations and 16,384 bytes of citation array JSON. Identifiers, titles and quotes are application content.

Summary

Functions

Build a citation for a custom model. Invalid fields raise ArgumentError. ExAgent.Message.new_response/2 checks that answer ranges fit the response.

Types

kind()

@type kind() :: :url | :attachment | :document

source()

@type source() :: String.t() | non_neg_integer()

t()

@type t() :: %ExAgent.Message.Citation{
  answer_range: ExAgent.Message.Citation.Range.t() | nil,
  kind: kind(),
  quote: String.t() | nil,
  source: source(),
  source_range: ExAgent.Message.Citation.Range.t() | nil,
  title: String.t() | nil
}

Functions

new(kind, source, opts \\ [])

@spec new(kind(), source(), keyword()) :: t()

Build a citation for a custom model. Invalid fields raise ArgumentError. ExAgent.Message.new_response/2 checks that answer ranges fit the response.