pub struct VectorCollectionContextProviderBuilder { /* private fields */ }Expand description
Builds a VectorCollectionContextProvider.
Implementations§
Source§impl VectorCollectionContextProviderBuilder
impl VectorCollectionContextProviderBuilder
Sourcepub fn source_id(
self,
source_id: impl Into<String>,
) -> VectorCollectionContextProviderBuilder
pub fn source_id( self, source_id: impl Into<String>, ) -> VectorCollectionContextProviderBuilder
Identify this provider in instruction and tool attribution. Defaults to
"vector_collection".
Sourcepub fn tool_prefix(
self,
prefix: impl Into<String>,
) -> VectorCollectionContextProviderBuilder
pub fn tool_prefix( self, prefix: impl Into<String>, ) -> VectorCollectionContextProviderBuilder
Prefix every generated tool’s name, e.g. "notes" gives
notes_search.
The generated names are otherwise the plain search / get /
upsert / delete upstream uses, which collide when an agent holds
two of these providers — or one of these and any other tool called
search. A collision is not a silent problem (the invocation loop
resolves a call by name and would pick one of them), which is exactly
why it is worth avoiding.
Sourcepub fn scope_filter(
self,
filter: impl Into<FilterExpression>,
) -> VectorCollectionContextProviderBuilder
pub fn scope_filter( self, filter: impl Into<FilterExpression>, ) -> VectorCollectionContextProviderBuilder
Scope every generated tool to the records matching filter. See the
module docs for what this does and does not guarantee.
Sourcepub fn instructions(
self,
instructions: Vec<String>,
) -> VectorCollectionContextProviderBuilder
pub fn instructions( self, instructions: Vec<String>, ) -> VectorCollectionContextProviderBuilder
Replace the generated instructions. An empty list adds none.
Sourcepub fn embed_from_field(
self,
field_name: impl Into<String>,
) -> VectorCollectionContextProviderBuilder
pub fn embed_from_field( self, field_name: impl Into<String>, ) -> VectorCollectionContextProviderBuilder
Enable the upsert tool, embedding the named data field’s text
into the collection’s vector field.
Without this there is no upsert tool, and build says so rather than
offering one that cannot work: a model cannot author a 1,536-float
embedding, and which of a collection’s fields carries the text it
should be derived from is a property of the schema that nothing in the
definition records. Upstream has no equivalent because its collection
owns an embedding generator and does this itself.
Sourcepub fn vector_field(
self,
name: impl Into<String>,
) -> VectorCollectionContextProviderBuilder
pub fn vector_field( self, name: impl Into<String>, ) -> VectorCollectionContextProviderBuilder
Name the vector field the generated tools use.
Only needed when the collection declares more than one, where there is
no safe default: searching the wrong embedding returns confident
nonsense rather than an error, so build refuses a
multi-vector collection that does not name one.
Sourcepub fn include_search(
self,
include: bool,
) -> VectorCollectionContextProviderBuilder
pub fn include_search( self, include: bool, ) -> VectorCollectionContextProviderBuilder
Whether to generate the similarity-search tool. On by default.
Sourcepub fn include_get(
self,
include: bool,
) -> VectorCollectionContextProviderBuilder
pub fn include_get( self, include: bool, ) -> VectorCollectionContextProviderBuilder
Whether to generate the read-by-key tool. On by default.
Sourcepub fn include_delete(
self,
include: bool,
) -> VectorCollectionContextProviderBuilder
pub fn include_delete( self, include: bool, ) -> VectorCollectionContextProviderBuilder
Whether to generate the delete-by-key tool. On by default.
Sourcepub fn approval_mode(
self,
kind: VectorToolKind,
mode: ApprovalMode,
) -> VectorCollectionContextProviderBuilder
pub fn approval_mode( self, kind: VectorToolKind, mode: ApprovalMode, ) -> VectorCollectionContextProviderBuilder
Override one tool’s approval mode. See
VectorToolKind::default_approval for the defaults.
Sourcepub fn max_tool_batch_size(
self,
max: usize,
) -> VectorCollectionContextProviderBuilder
pub fn max_tool_batch_size( self, max: usize, ) -> VectorCollectionContextProviderBuilder
Cap how many records or keys one tool call may carry. See
DEFAULT_MAX_TOOL_BATCH_SIZE.
Sourcepub fn search_top(self, top: usize) -> VectorCollectionContextProviderBuilder
pub fn search_top(self, top: usize) -> VectorCollectionContextProviderBuilder
How many hits the search tool returns. See DEFAULT_SEARCH_TOP.
Sourcepub fn search_embedding_options(
self,
options: EmbeddingGenerationOptions,
) -> VectorCollectionContextProviderBuilder
pub fn search_embedding_options( self, options: EmbeddingGenerationOptions, ) -> VectorCollectionContextProviderBuilder
Provider options for the embedding call the search tool makes.
Searching and indexing are different operations, and for some
providers the same text must be embedded differently for each. Gemini
Embedding 2 is the clearest case: it conditions the vector on what the
text is for and requires that to be stated, so a Gemini embedding
client could not serve a vector store at all until these options
existed — a retrieval-query task belongs here and a retrieval-document
task on upsert_embedding_options.
For providers that draw no such distinction, leaving both unset is
right, and is exactly what happened before.
Rust analogue of upstream’s per-operation embeddings_options
(#8798). Split by operation rather than by field, because one provider
has one vector field and it is the operation that differs.
dimensions is taken from the vector field’s declaration; passing a
conflicting value here is an error at build rather
than a store rejection — or worse, a silently mis-shaped vector — at
the first call.
Sourcepub fn upsert_embedding_options(
self,
options: EmbeddingGenerationOptions,
) -> VectorCollectionContextProviderBuilder
pub fn upsert_embedding_options( self, options: EmbeddingGenerationOptions, ) -> VectorCollectionContextProviderBuilder
Provider options for the embedding call the upsert tool makes.
See search_embedding_options; this
is the indexing side, where a retrieval-document task belongs.
Sourcepub fn additional_tool(
self,
tool: ToolDefinition,
) -> VectorCollectionContextProviderBuilder
pub fn additional_tool( self, tool: ToolDefinition, ) -> VectorCollectionContextProviderBuilder
Add a caller-built tool alongside the generated ones.
These are passed through untouched — in particular the scope filter is not applied to them, so a tool that searches a shared collection has to carry its own.
Sourcepub fn build(self) -> Result<VectorCollectionContextProvider, Error>
pub fn build(self) -> Result<VectorCollectionContextProvider, Error>
Validate the configuration and build the provider.