Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface {
// Embed generates embeddings for the given texts
//
// Parameters:
// - ctx: Context for cancellation and timeout
// - texts: Slice of texts to embed
//
// Returns:
// - [][]float32: Slice of embeddings, one for each text
// - error: Error if embedding generation fails
Embed(ctx context.Context, texts []string) ([][]float32, error)
// Dimension returns the dimension of the embeddings generated by this provider
//
// Returns:
// - int: Embedding dimension (e.g., 1536 for text-embedding-ada-002)
Dimension() int
}
Provider defines the interface for embedding providers
This interface is implemented by all embedding model providers (OpenAI, Ollama, Cohere, Voyage) and allows the RAG engine to generate embeddings for text chunks.
Example implementation:
type OpenAIProvider struct {
client *openai.Client
model string
}
func (p *OpenAIProvider) Embed(ctx context.Context, texts []string) ([][]float32, error) {
// Call OpenAI API to generate embeddings
}
func (p *OpenAIProvider) Dimension() int {
return 1536 // text-embedding-ada-002 dimension
}
Click to show internal directories.
Click to hide internal directories.