ContextLayer

ContextLayer(docs=())

Text that helps an agent interpret its data source.

Construct one with :func:context_layer. Internals are private and may change without notice.

Attributes

Name Description
docs The documents as read from their files, frontmatter stripped.

Methods

Name Description
prewarm Build the index now so the first search does not pay for it.
search Retrieve the chunks most relevant to query.

prewarm

ContextLayer.prewarm()

Build the index now so the first search does not pay for it.

Optional and idempotent; worth calling when a search is known to be coming, so its cost does not land on the first user turn.

search

ContextLayer.search(query, top_k=3)

Retrieve the chunks most relevant to query.

Returns chunk texts, best match first, at most top_k of them. An empty layer, or a query nothing matches, returns an empty list. top_k must be at least 1.