Skip to contents

Retrieves context snippets from an assistant's documents without generating a chat response. Useful for RAG pipelines or agentic flows where you want to handle the context yourself.

Usage

assistant_context(
  assistant_name,
  query,
  filter = NULL,
  top_k = NULL,
  snippet_size = NULL
)

Arguments

assistant_name

Name of the assistant

query

The query text to find relevant context for

filter

Optional metadata filter to limit which files are searched (list)

top_k

Number of context snippets to retrieve (default: 15)

snippet_size

Maximum size of each snippet in tokens (optional)

Value

List with http response, content (context snippets), and status_code. Content includes a "snippets" list where each snippet has: - type: Snippet type (e.g., "text") - content: The text content of the snippet - score: Relevance score - reference: Reference information including: - type: Document type (e.g., "pdf") - file: File information - pages: Page numbers referenced

Examples

if (FALSE) { # \dontrun{
# Get context for a query
assistant_context(
  assistant_name = "my-assistant",
  query = "Who is the CFO?"
)

# Get context with filter
assistant_context(
  assistant_name = "my-assistant",
  query = "What are the revenue figures?",
  filter = list(document_type = "financial"),
  top_k = 10
)
} # }