Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get retrieves cached embeddings for texts Get(ctx context.Context, texts []string) ([][]float32, []bool, error) // Set stores embeddings for texts Set(ctx context.Context, texts []string, embeddings [][]float32) error // Clear removes all cached embeddings Clear(ctx context.Context) error // Close releases any resources used by the cache Close() error }
Cache provides caching for embeddings to avoid regenerating them
type CachedModel ¶
type CachedModel struct {
// contains filtered or unexported fields
}
CachedModel wraps an embedding model with caching
func NewCachedModel ¶
func NewCachedModel(model Model, cache Cache) *CachedModel
NewCachedModel creates a new cached embedding model
func (*CachedModel) Dimension ¶
func (m *CachedModel) Dimension() int
Dimension implements Model.Dimension
type Config ¶
type Config struct { Type string `json:"type"` // Type of embedding model Options map[string]interface{} `json:"options,omitempty"` // Model-specific options }
Config holds configuration for embedding models
type LocalModel ¶
type LocalModel struct {
// contains filtered or unexported fields
}
LocalModel implements Model using a simple hashing-based approach This is only for testing and should not be used in production
func (*LocalModel) Dimension ¶
func (m *LocalModel) Dimension() int
Dimension implements Model.Dimension
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache provides in-memory caching for embeddings
func NewMemoryCache ¶
func NewMemoryCache() *MemoryCache
NewMemoryCache creates a new in-memory cache
func (*MemoryCache) Clear ¶
func (c *MemoryCache) Clear(ctx context.Context) error
Clear implements Cache.Clear
type Model ¶
type Model interface { // Embed generates embeddings for the given texts Embed(ctx context.Context, texts []string) ([][]float32, error) // Dimension returns the dimension of the embeddings Dimension() int // Close releases any resources used by the model Close() error }
Model represents a text embedding model
func NewLocalModel ¶
NewLocalModel creates a new local embedding model
func NewOpenAIModel ¶
NewOpenAIModel creates a new OpenAI embedding model
type OpenAIModel ¶
type OpenAIModel struct {
// contains filtered or unexported fields
}
OpenAIModel implements Model using OpenAI's API
func (*OpenAIModel) Dimension ¶
func (m *OpenAIModel) Dimension() int
Dimension implements Model.Dimension
type VertexAIModel ¶
type VertexAIModel struct {
// contains filtered or unexported fields
}
VertexAIModel implements Model using Google's Vertex AI
func (*VertexAIModel) Dimension ¶
func (m *VertexAIModel) Dimension() int
Dimension implements Model.Dimension