Captain is currently in ALPHA. We are happy to get your feedback
SDK
Use Vector Store

Module: use-vector-store

Table of contents

Functions

Functions

useVectorScroll

useVectorScroll({?): Object

Custom React hook to interact with the vector store for scrolling through large datasets.

This hook manages the state of scrolling operations within a vector store, sending scroll parameters to the vector store and managing the state of the scroll results. It provides a continuous way to retrieve large sets of results where the dataset is too large to feasibly return at once, using debounced filter settings to minimize unnecessary queries.

Parameters

NameTypeDescription
{?ScrollOptionsThe scrolling options including ordering, payload inclusion, limit, and filtering criteria to tailor the scroll results.

Returns

Object

An object containing an array of VectorStoreResponse objects representing the scroll results, an error object if an error occurs, and a mutate function to manually trigger state updates.

NameType
dataVectorStoreResponse[]
errornull | Error
mutateFunction

Example

// In a React component
const { data, error, mutate } = useVectorScroll({ order_by: 'date', limit: 10 });
// data will contain an array of VectorStoreResponses, each representing a chunk of the vector store data
// error will contain any error that occurred during the scroll operation
// mutate can be used to manually update the scroll results

Defined in

react/dist/esm/use-vector-store/index.js:92


useVectorStore

useVectorStore(query, {?): Object

Custom React hook to interact with the vector store, providing search functionality.

This hook manages a search query against a vector store, debouncing the input value to avoid excessive querying. It sends the debounced query to the vector store and manages the state of the search results, providing real-time feedback as the user types.

Parameters

NameTypeDescription
querystringThe initial search query string.
{?anyThe search options including score threshold, filter criteria, and limit to filter the results.

Returns

Object

An object containing the search results as an array of VectorStoreResponse objects, an error object if an error occurs, and a mutate function to manually trigger state updates.

NameType
dataVectorStoreResponse[]
errornull | Error
mutateFunction

Example

// In a React component
const { data, error, mutate } = useVectorStore('search term', { score_threshold: 0.5 });
// data will contain an array of search responses where each item has a score above 0.5
// error will contain any error that occurred during the search
// mutate can be used to manually update the search results

Defined in

react/dist/esm/use-vector-store/index.js:25