backend

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// SaveConversation stores a conversation thread and its messages
	SaveConversation(ctx context.Context, thread *conversation.Thread, messages []conversation.Message) error

	// LoadConversation retrieves a conversation thread and its messages
	LoadConversation(ctx context.Context, threadID string) (*conversation.Thread, []conversation.Message, error)

	// SearchConversations searches for conversations matching the query
	SearchConversations(ctx context.Context, query string, limit int) ([]*conversation.Thread, error)

	// DeleteConversation deletes a conversation thread and its messages
	DeleteConversation(ctx context.Context, threadID string) error

	// SaveVector stores a vector with associated metadata
	SaveVector(ctx context.Context, id string, vec vector.Vector, metadata map[string]interface{}) error

	// LoadVector retrieves a vector by ID
	LoadVector(ctx context.Context, id string) (vector.Vector, map[string]interface{}, error)

	// SearchVectors searches for similar vectors
	SearchVectors(ctx context.Context, queryVec vector.Vector, limit int) ([]vector.SearchResult, error)

	// DeleteVector deletes a vector by ID
	DeleteVector(ctx context.Context, id string) error

	// Close closes the backend
	Close() error
}

Backend defines the interface for memory storage

type MemoryBackend

type MemoryBackend struct {
	// contains filtered or unexported fields
}

MemoryBackend provides an in-memory implementation of the Backend interface

func NewMemoryBackend

func NewMemoryBackend(vectorStore vector.Store) *MemoryBackend

NewMemoryBackend creates a new in-memory backend

func (*MemoryBackend) Close

func (b *MemoryBackend) Close() error

Close implements Backend.Close

func (*MemoryBackend) DeleteConversation

func (b *MemoryBackend) DeleteConversation(ctx context.Context, threadID string) error

DeleteConversation implements Backend.DeleteConversation

func (*MemoryBackend) DeleteVector

func (b *MemoryBackend) DeleteVector(ctx context.Context, id string) error

DeleteVector implements Backend.DeleteVector

func (*MemoryBackend) LoadConversation

func (b *MemoryBackend) LoadConversation(ctx context.Context, threadID string) (*conversation.Thread, []conversation.Message, error)

LoadConversation implements Backend.LoadConversation

func (*MemoryBackend) LoadVector

func (b *MemoryBackend) LoadVector(ctx context.Context, id string) (vector.Vector, map[string]interface{}, error)

LoadVector implements Backend.LoadVector

func (*MemoryBackend) SaveConversation

func (b *MemoryBackend) SaveConversation(ctx context.Context, thread *conversation.Thread, messages []conversation.Message) error

SaveConversation implements Backend.SaveConversation

func (*MemoryBackend) SaveVector

func (b *MemoryBackend) SaveVector(ctx context.Context, id string, vec vector.Vector, metadata map[string]interface{}) error

SaveVector implements Backend.SaveVector

func (*MemoryBackend) SearchConversations

func (b *MemoryBackend) SearchConversations(ctx context.Context, query string, limit int) ([]*conversation.Thread, error)

SearchConversations implements Backend.SearchConversations

func (*MemoryBackend) SearchVectors

func (b *MemoryBackend) SearchVectors(ctx context.Context, queryVec vector.Vector, limit int) ([]vector.SearchResult, error)

SearchVectors implements Backend.SearchVectors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL