Skip to Content
SdkReactInternalFunctionscreateMemoryRetrievalTool

createMemoryRetrievalTool

createMemoryRetrievalTool(storageCtx: StorageOperationsContext, embeddingOptions: MemoryRetrievalEmbeddingOptions, searchOptions?: Partial<MemoryRetrievalSearchOptions>): ToolConfig

Defined in: src/lib/memoryRetrieval/tool.ts:87 

Creates a memory retrieval tool for use with chat completions.

The tool allows the LLM to search through past conversation messages using semantic similarity. Messages must have embeddings stored to be searchable.

Parameters

ParameterTypeDescription

storageCtx

StorageOperationsContext

Storage operations context for database access

embeddingOptions

MemoryRetrievalEmbeddingOptions

Options for embedding generation

searchOptions?

Partial<MemoryRetrievalSearchOptions>

Default search options (can be overridden per-call)

Returns

ToolConfig

A ToolConfig that can be passed to chat completion tools

Example

const tool = createMemoryRetrievalTool( storageCtx, { getToken: () => getIdentityToken() }, { limit: 5, minSimilarity: 0.4 } ); // Use with chat completion const result = await sendMessage({ messages: [...], tools: [tool], });
Last updated on