Memory Layer
The Memory Layer provides knowledge storage with automatic embedding generation and semantic search.
memory.store()
Store knowledge in the Memory Layer with automatic embedding generation.
Signature
typescript
store(params: StoreParams): Promise<StoreResponse>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| content | string | Yes | The content to store |
| tags | string[] | No | Tags for organization |
| metadata | object | No | Additional metadata |
Returns
typescript
{
id: string; // Unique identifier
embedding: number[]; // Generated embedding vector
createdAt: Date; // Timestamp
}Example
typescript
const result = await client.memory.store({
content: "CognitiveX provides multi-LLM support",
tags: ["features", "llm"],
metadata: {
category: "product",
version: "1.0"
}
});
console.log('Stored with ID:', result.id);memory.search()
Search stored knowledge using semantic similarity.
Signature
typescript
search(params: SearchParams): Promise<SearchResponse>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | Search query |
| limit | number | No | Max results (default: 10) |
| tags | string[] | No | Filter by tags |
Example
typescript
const results = await client.memory.search({
query: "multi-LLM support",
limit: 5,
tags: ["features"]
});
results.forEach(item => {
console.log(`${item.content} (score: ${item.score})`);
});Best Practices
- • Use descriptive tags for better organization
- • Include relevant metadata for filtering
- • Keep content chunks focused (200-500 words)
- • Use batch operations for multiple items
- • Cache frequently accessed items client-side