Skip to main content
Query knowledge bases to retrieve relevant content using semantic search. Use results directly or pass knowledge bases to agents for RAG-powered responses.

Quick Start


kb.query()

Search the knowledge base for relevant content.

Parameters

Example


Retrieval Types

basic

Standard vector similarity search. Default and fastest option.

mmr (Maximal Marginal Relevance)

Returns diverse results by reducing redundancy. Useful when you want varied perspectives.

hyde (Hypothetical Document Embeddings)

Generates a hypothetical answer first, then searches for similar content. Better for question-style queries.

time_aware

Weights results by recency. Useful for content where freshness matters.

QueryResult Object

Each result is a QueryResult with these properties:

Working with Results


Using with Agents

Pass knowledge bases to agent.run() for RAG-powered responses.

Basic Usage

Multiple Knowledge Bases

Custom Runtime Configuration

Use with_config() to customize retrieval settings per-call:

kb.with_config()

Create a runtime configuration for custom retrieval settings.

Parameters

Examples


Examples

Q&A Bot


Best Practices

Query Formatting

Score Thresholds

Choosing top_k