Documentation
¶
Index ¶
- type EmbeddingModel
- type OpenAICompatibleEmbedding
- type OpenAICompatibleEmbeddingConfig
- type PostgresMemoryService
- func (s *PostgresMemoryService) AddSession(ctx context.Context, sess session.Session) error
- func (s *PostgresMemoryService) Close() error
- func (s *PostgresMemoryService) DB() *sql.DB
- func (s *PostgresMemoryService) DeleteMemory(ctx context.Context, appName, userID string, entryID int) error
- func (s *PostgresMemoryService) Search(ctx context.Context, req *memory.SearchRequest) (*memory.SearchResponse, error)
- func (s *PostgresMemoryService) SearchWithID(ctx context.Context, req *memory.SearchRequest) ([]memorytypes.EntryWithID, error)
- func (s *PostgresMemoryService) UpdateMemory(ctx context.Context, appName, userID string, entryID int, newContent string) error
- type PostgresMemoryServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbeddingModel ¶
type EmbeddingModel interface {
Embed(ctx context.Context, text string) ([]float32, error)
Dimension() int
}
EmbeddingModel is an interface for generating embeddings from text.
type OpenAICompatibleEmbedding ¶
type OpenAICompatibleEmbedding struct {
BaseURL string // e.g., "https://api.openai.com/v1", "http://localhost:11434/v1"
APIKey string // optional, not required for local models
Model string // e.g., "text-embedding-3-small", "nomic-embed-text"
// HTTPClient allows customizing the HTTP client used for requests.
// If nil, http.DefaultClient is used.
HTTPClient *http.Client
// contains filtered or unexported fields
}
OpenAICompatibleEmbedding implements EmbeddingModel using the OpenAI embeddings API format. This is the de facto standard supported by: OpenAI, Ollama (/v1), Azure OpenAI, vLLM, LocalAI, LiteLLM, etc.
func NewOpenAICompatibleEmbedding ¶
func NewOpenAICompatibleEmbedding(cfg OpenAICompatibleEmbeddingConfig) *OpenAICompatibleEmbedding
NewOpenAICompatibleEmbedding creates a new embedding model using OpenAI-compatible API. Works with OpenAI, Ollama, vLLM, LocalAI, LiteLLM, Azure OpenAI, etc.
func (*OpenAICompatibleEmbedding) Dimension ¶
func (e *OpenAICompatibleEmbedding) Dimension() int
Dimension returns the embedding dimension. Returns 0 if not yet known (will be auto-detected on first Embed call).
type OpenAICompatibleEmbeddingConfig ¶
type OpenAICompatibleEmbeddingConfig struct {
BaseURL string
APIKey string
Model string
Dimension int // optional, will be auto-detected on first call if 0
// HTTPClient allows customizing the HTTP client used for requests.
// Useful for testing with mock servers.
HTTPClient *http.Client
}
OpenAICompatibleEmbeddingConfig holds configuration for the embedding model.
type PostgresMemoryService ¶
type PostgresMemoryService struct {
// contains filtered or unexported fields
}
PostgresMemoryService implements memory.Service using PostgreSQL with pgvector.
func NewPostgresMemoryService ¶
func NewPostgresMemoryService(ctx context.Context, cfg PostgresMemoryServiceConfig) (*PostgresMemoryService, error)
NewPostgresMemoryService creates a new PostgreSQL-backed memory service.
func (*PostgresMemoryService) AddSession ¶
AddSession extracts memory entries from a session and stores them.
func (*PostgresMemoryService) Close ¶
func (s *PostgresMemoryService) Close() error
Close closes the database connection.
func (*PostgresMemoryService) DB ¶
func (s *PostgresMemoryService) DB() *sql.DB
DB returns the underlying database connection for testing purposes.
func (*PostgresMemoryService) DeleteMemory ¶ added in v0.2.0
func (s *PostgresMemoryService) DeleteMemory(ctx context.Context, appName, userID string, entryID int) error
DeleteMemory deletes a memory entry by ID, scoped to app and user.
func (*PostgresMemoryService) Search ¶
func (s *PostgresMemoryService) Search(ctx context.Context, req *memory.SearchRequest) (*memory.SearchResponse, error)
Search finds relevant memory entries for a query.
func (*PostgresMemoryService) SearchWithID ¶ added in v0.2.0
func (s *PostgresMemoryService) SearchWithID(ctx context.Context, req *memory.SearchRequest) ([]memorytypes.EntryWithID, error)
SearchWithID finds relevant memory entries including their database IDs.
func (*PostgresMemoryService) UpdateMemory ¶ added in v0.2.0
func (s *PostgresMemoryService) UpdateMemory(ctx context.Context, appName, userID string, entryID int, newContent string) error
UpdateMemory updates the content of a memory entry by ID, scoped to app and user.
type PostgresMemoryServiceConfig ¶
type PostgresMemoryServiceConfig struct {
// ConnString is the PostgreSQL connection string
// e.g., "postgres://user:pass@localhost:5432/dbname?sslmode=disable"
ConnString string
// EmbeddingModel is used to generate embeddings for semantic search (optional)
EmbeddingModel EmbeddingModel
}
PostgresMemoryServiceConfig holds configuration for PostgresMemoryService.