Documentation
¶
Index ¶
- Constants
- func AllEmbeddings(rec MemoryRecord) [][]float32
- func CloneMetadata(meta map[string]any) map[string]any
- func CosineSimilarity(a, b []float32) float64
- func CosineSimilarityMatrix(query []float32, matrix [][]float32) float64
- func DecodeEmbeddingMatrix(raw any) [][]float32
- func DecodeMetadata(metadata string) map[string]any
- func FloatFromAny(v any) float64
- func HydrateRecordFromMetadata(rec *MemoryRecord, meta map[string]any)
- func MaxCosineSimilarity(query []float32, rec MemoryRecord) float64
- func NormalizeMetadata(meta map[string]any, fallback time.Time) (importance float64, source, summary string, lastEmbedded time.Time, ...)
- func RecordSimilarity(a, b MemoryRecord) float64
- func RepresentativeEmbedding(rec MemoryRecord) []float32
- func SanitizeEmbeddingMatrix(meta map[string]any) [][]float32
- func StringFromAny(v any) string
- func TimeFromAny(v any) time.Time
- func ValidEmbeddingMatrix(meta map[string]any) [][]float32
- type EdgeType
- type GraphEdge
- type MemoryRecord
Constants ¶
const EmbeddingMatrixKey = "embedding_matrix"
EmbeddingMatrixKey is the metadata field used for multi-vector support.
Variables ¶
This section is empty.
Functions ¶
func AllEmbeddings ¶
func AllEmbeddings(rec MemoryRecord) [][]float32
AllEmbeddings returns every embedding vector associated with the record.
func CosineSimilarity ¶
CosineSimilarity computes the cosine similarity between two vectors.
func CosineSimilarityMatrix ¶
CosineSimilarityMatrix computes the best cosine similarity between a query vector and any vector contained within the matrix.
func DecodeEmbeddingMatrix ¶
DecodeEmbeddingMatrix coerces arbitrary inputs into a matrix of float32 vectors.
func DecodeMetadata ¶
func FloatFromAny ¶
func HydrateRecordFromMetadata ¶
func HydrateRecordFromMetadata(rec *MemoryRecord, meta map[string]any)
func MaxCosineSimilarity ¶
func MaxCosineSimilarity(query []float32, rec MemoryRecord) float64
MaxCosineSimilarity returns the highest cosine similarity between the query vector and any embedding associated with the record.
func NormalizeMetadata ¶
func RecordSimilarity ¶
func RecordSimilarity(a, b MemoryRecord) float64
RecordSimilarity computes the maximum similarity between any pair of embeddings contained within the two records.
func RepresentativeEmbedding ¶
func RepresentativeEmbedding(rec MemoryRecord) []float32
RepresentativeEmbedding returns the first non-empty embedding from the record.
func SanitizeEmbeddingMatrix ¶
SanitizeEmbeddingMatrix normalizes the embedding matrix stored in metadata.
func StringFromAny ¶
func TimeFromAny ¶
func ValidEmbeddingMatrix ¶
ValidEmbeddingMatrix extracts a validated embedding matrix from metadata.
Types ¶
type EdgeType ¶
type EdgeType string
EdgeType enumerates supported knowledge graph relationships between memories.
type GraphEdge ¶
GraphEdge represents a typed, directed connection between two memory nodes.
func DecodeGraphEdges ¶
decodeGraphEdges attempts to coerce arbitrary metadata into []GraphEdge.
func SanitizeGraphEdges ¶
sanitizeGraphEdges normalizes the metadata map and extracts the edge list.
func ValidGraphEdges ¶
type MemoryRecord ¶
type MemoryRecord struct {
ID int64 `json:"id"`
SessionID string `json:"session_id"`
Space string `json:"space"`
Content string `json:"content"`
Metadata string `json:"metadata"`
Embedding []float32 `json:"embedding"`
EmbeddingMatrix [][]float32 `json:"embedding_matrix,omitempty"`
Score float64 `json:"score"`
KeywordScore float64 `json:"keyword_score"`
Importance float64 `json:"importance"`
Source string `json:"source"`
Summary string `json:"summary"`
CreatedAt time.Time `json:"created_at"`
LastEmbedded time.Time `json:"last_embedded"`
WeightedScore float64 `json:"weighted_score"`
GraphEdges []GraphEdge `json:"graph_edges"`
}
MemoryRecord represents a persisted memory entry in the vector store.