Documentation
¶
Overview ¶
Package omnimemory provides a vendor-neutral memory abstraction layer for multiple memory backends (PostgreSQL+pgvector, Mem0, Graphiti, Twilio Memory).
Overview ¶
OmniMemory provides a stable API for storing and retrieving memories with semantic search capabilities. It supports multiple backends through a provider interface, allowing you to switch between implementations without changing application code.
Quick Start ¶
import (
"github.com/plexusone/omnimemory"
"github.com/plexusone/omnimemory/core"
_ "github.com/plexusone/omnimemory/provider/memory" // Register in-memory provider
_ "github.com/plexusone/omnimemory/provider/postgres" // Register PostgreSQL provider
)
func main() {
// Create a client with in-memory provider (for testing)
client, err := omnimemory.NewClient(core.ClientConfig{
Providers: []core.ProviderConfig{
{Name: core.ProviderNameMemory},
},
})
if err != nil {
log.Fatal(err)
}
defer client.Close()
// Add a memory
memory, err := client.Add(ctx, &core.AddRequest{
Context: core.Context{
TenantID: "tenant-1",
SubjectID: "user-123",
},
Type: core.MemoryTypeFact,
Content: "User prefers dark mode",
})
// Search memories
results, err := client.Search(ctx, &core.SearchRequest{
Context: core.Context{
TenantID: "tenant-1",
SubjectID: "user-123",
},
Query: "user interface preferences",
Limit: 10,
})
}
Memory Types ¶
OmniMemory supports different types of memories:
- Observation: Observed behavior or interaction
- Fact: Verified piece of information
- Preference: User preference
- Summary: Summarized conversation or topic
- Trait: Personality trait or characteristic
- Relationship: Relationship between entities
Memory Scopes ¶
Memories can be scoped at different levels:
- User: Personal to one user
- Agent: What an agent has learned
- Tenant: Org-level shared memories
- Team: Group/project level memories
- Session: Short-lived conversation memories
- Domain: Domain-specific memories (support, sales, etc.)
Providers ¶
Available providers:
- memory: In-memory provider for testing
- postgres: PostgreSQL+pgvector for production
- mem0: Mem0 adapter (future)
- graphiti: Graphiti temporal knowledge graph (future)
- twilio: Twilio Memory API (future)
Index ¶
- Constants
- Variables
- func CosineSimilarity(a, b []float64) float64
- func EuclideanDistance(a, b []float64) float64
- func RegisterProvider(name ProviderName, factory core.ProviderFactory, priority int)
- type AddRequest
- type Client
- type ClientConfig
- type Context
- type DeleteRequest
- type Embedder
- type Fact
- type GetRequest
- type ListRequest
- type ListResponse
- type Memory
- type MemoryType
- type Observation
- type Provider
- type ProviderConfig
- type ProviderName
- type RecallRequest
- type RecallResponse
- type Scope
- type SearchRequest
- type SearchResponse
- type SearchResult
- type UpdateRequest
Constants ¶
const ( MemoryTypeObservation = core.MemoryTypeObservation MemoryTypeFact = core.MemoryTypeFact MemoryTypePreference = core.MemoryTypePreference MemoryTypeSummary = core.MemoryTypeSummary MemoryTypeTrait = core.MemoryTypeTrait MemoryTypeRelationship = core.MemoryTypeRelationship )
Re-export memory types.
const ( ScopeUser = core.ScopeUser ScopeAgent = core.ScopeAgent ScopeTenant = core.ScopeTenant ScopeTeam = core.ScopeTeam ScopeSession = core.ScopeSession ScopeDomain = core.ScopeDomain )
Re-export scopes.
const ( ProviderNameMemory = core.ProviderNameMemory ProviderNamePostgres = core.ProviderNamePostgres ProviderNameMem0 = core.ProviderNameMem0 ProviderNameGraphiti = core.ProviderNameGraphiti ProviderNameTwilio = core.ProviderNameTwilio )
Re-export provider names.
const ( PriorityThin = core.PriorityThin PriorityThick = core.PriorityThick )
Re-export priority constants.
Variables ¶
var ( ErrNotFound = core.ErrNotFound ErrInvalidInput = core.ErrInvalidInput ErrProviderNotFound = core.ErrProviderNotFound ErrNoProviders = core.ErrNoProviders ErrEmbeddingFailed = core.ErrEmbeddingFailed ErrTenantRequired = core.ErrTenantRequired ErrSubjectRequired = core.ErrSubjectRequired ErrContentRequired = core.ErrContentRequired )
Re-export errors.
Functions ¶
func CosineSimilarity ¶
CosineSimilarity computes the cosine similarity between two vectors.
func EuclideanDistance ¶
EuclideanDistance computes the Euclidean distance between two vectors.
func RegisterProvider ¶
func RegisterProvider(name ProviderName, factory core.ProviderFactory, priority int)
RegisterProvider registers a provider factory with the global registry.
Types ¶
type AddRequest ¶
type AddRequest = core.AddRequest
AddRequest is the request for adding a new memory.
type Client ¶
Client is a multi-provider memory client with fallback support.
func NewClient ¶
func NewClient(config ClientConfig) (*Client, error)
NewClient creates a new multi-provider memory client.
type ClientConfig ¶
type ClientConfig = core.ClientConfig
ClientConfig is the configuration for creating a Client.
type DeleteRequest ¶
type DeleteRequest = core.DeleteRequest
DeleteRequest is the request for deleting a memory.
type GetRequest ¶
type GetRequest = core.GetRequest
GetRequest is the request for getting a memory by ID.
type ListRequest ¶
type ListRequest = core.ListRequest
ListRequest is the request for listing memories.
type ListResponse ¶
type ListResponse = core.ListResponse
ListResponse is the response for listing memories.
type MemoryType ¶
type MemoryType = core.MemoryType
MemoryType defines the category of memory content.
type Observation ¶
type Observation = core.Observation
Observation represents an observed behavior or interaction.
type Provider ¶
Provider is the interface that all memory providers must implement.
func GetProvider ¶
func GetProvider(name ProviderName, config ProviderConfig, embedder Embedder) (Provider, error)
GetProvider creates a provider instance from the global registry.
type ProviderConfig ¶
type ProviderConfig = core.ProviderConfig
ProviderConfig is the configuration for initializing a provider.
type ProviderName ¶
type ProviderName = core.ProviderName
ProviderName identifies a provider type.
func ListProviders ¶
func ListProviders() []ProviderName
ListProviders returns all registered provider names.
type RecallRequest ¶
type RecallRequest = core.RecallRequest
RecallRequest is the request for recalling relevant memories.
type RecallResponse ¶
type RecallResponse = core.RecallResponse
RecallResponse is the response for recalling memories.
type SearchRequest ¶
type SearchRequest = core.SearchRequest
SearchRequest is the request for semantic search.
type SearchResponse ¶
type SearchResponse = core.SearchResponse
SearchResponse is the response for semantic search.
type SearchResult ¶
type SearchResult = core.SearchResult
SearchResult is a single search result with similarity score.
type UpdateRequest ¶
type UpdateRequest = core.UpdateRequest
UpdateRequest is the request for updating a memory.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package core provides the core types and interfaces for omnimemory.
|
Package core provides the core types and interfaces for omnimemory. |
|
providertest
Package providertest provides conformance tests for memory provider implementations.
|
Package providertest provides conformance tests for memory provider implementations. |
|
Package ent provides the generated Ent ORM code.
|
Package ent provides the generated Ent ORM code. |
|
provider
|
|
|
graphiti
Package graphiti provides a Graphiti Provider implementation (future).
|
Package graphiti provides a Graphiti Provider implementation (future). |
|
kvs
Package kvs provides a KVS-backed Provider implementation using omnistorage-core.
|
Package kvs provides a KVS-backed Provider implementation using omnistorage-core. |
|
mem0
Package mem0 is a placeholder for the mem0 provider.
|
Package mem0 is a placeholder for the mem0 provider. |
|
memory
Package memory provides an in-memory Provider implementation for testing.
|
Package memory provides an in-memory Provider implementation for testing. |
|
postgres
Package postgres provides a PostgreSQL+pgvector Provider implementation via Ent.
|
Package postgres provides a PostgreSQL+pgvector Provider implementation via Ent. |
|
twilio
Package twilio is a placeholder for the Twilio Memory provider.
|
Package twilio is a placeholder for the Twilio Memory provider. |