Skip to Content
Anuma SDKReactInternalFunctionscreateMemoryEngineTool

createMemoryEngineTool

createMemoryEngineTool(storageCtx: StorageOperationsContext, embeddingOptions: MemoryEngineEmbeddingOptions, searchOptions?: Partial<MemoryEngineSearchOptions>, callbacks?: object): ToolConfig

Defined in: src/lib/memoryEngine/tool.ts:93 

Creates a memory engine 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

MemoryEngineEmbeddingOptions

Options for embedding generation

searchOptions?

Partial<MemoryEngineSearchOptions>

Default search options (can be overridden per-call)

callbacks?

object

callbacks.onRetrieve?

(conversationIds: string[]) => void

Called after retrieval with the conversation IDs that were actually returned to the LLM.

Returns

ToolConfig

A ToolConfig that can be passed to chat completion tools

Example

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