MeilisearchMemoryDriver
in package
implements
MemoryService
Table of Contents
Interfaces
Properties
- $client : Client
- $indexName : string
Methods
- __construct() : mixed
- delete() : void
- Delete memory entries for a source
- search() : array<string|int, mixed>
- Search for similar content using Meilisearch vector search
- store() : void
- Store content with embedding in memory
- cosineSimilarity() : float
- Calculate cosine similarity between two vectors
- ensureIndex() : void
- Ensure the index exists with proper configuration
Properties
$client
protected
Client
$client
$indexName
protected
string
$indexName
Methods
__construct()
public
__construct(string $host[, string|null $key = null ][, string $indexName = 'ai_assistant_memory' ]) : mixed
Parameters
- $host : string
- $key : string|null = null
- $indexName : string = 'ai_assistant_memory'
delete()
Delete memory entries for a source
public
delete(int $userId, string $sourceType, int $sourceId) : void
Parameters
- $userId : int
- $sourceType : string
- $sourceId : int
search()
Search for similar content using Meilisearch vector search
public
search(int $userId, array<string|int, mixed> $queryEmbedding[, int $limit = 10 ][, float $threshold = 0.7 ]) : array<string|int, mixed>
Parameters
- $userId : int
- $queryEmbedding : array<string|int, mixed>
- $limit : int = 10
- $threshold : float = 0.7
Return values
array<string|int, mixed> —Array of ['content' => string, 'metadata' => array, 'score' => float]
store()
Store content with embedding in memory
public
store(int $userId, string $sourceType, int $sourceId, string $content, array<string|int, mixed> $embedding[, array<string|int, mixed> $metadata = [] ]) : void
Parameters
- $userId : int
- $sourceType : string
- $sourceId : int
- $content : string
- $embedding : array<string|int, mixed>
- $metadata : array<string|int, mixed> = []
cosineSimilarity()
Calculate cosine similarity between two vectors
protected
cosineSimilarity(array<string|int, mixed> $a, array<string|int, mixed> $b) : float
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>
Return values
floatensureIndex()
Ensure the index exists with proper configuration
protected
ensureIndex() : void