embedding

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 1 Imported by: 0

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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