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
| Parameter | Type | Description |
|---|---|---|
|
|
Storage operations context for database access | |
|
|
Options for embedding generation | |
|
|
|
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