embedding

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderNonOKResponse = errors.New("embedding provider returned non-OK status")

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider    string      `json:"provider"`
	Model       string      `json:"model"`
	Credentials Credentials `json:"credentials,omitempty"`
}

type Creator

type Creator interface {
	Generate(ctx context.Context, text, model string, cfg *Config) (*Embedding, error)
}

type Credentials

type Credentials struct {
	APIKey      string `json:"api_key,omitempty"` // #nosec G117
	HeaderName  string `json:"header_name,omitempty"`
	HeaderValue string `json:"header_value,omitempty"`
}

type Embedding

type Embedding struct {
	EntityID  string    `json:"entity_id"`
	Value     []float64 `json:"value"`
	CreatedAt time.Time `json:"created_at"`
}

func (*Embedding) ToBlob

func (e *Embedding) ToBlob() ([]byte, error)

type Repository

type Repository interface {
	Count(ctx context.Context, index, keyQuery string) (int, error)
	Store(ctx context.Context, targetID string, embeddingData *Embedding, key string) error
	GetByTargetID(ctx context.Context, targetID string) (*Embedding, error)
	StoreWithHMSet(ctx context.Context, index, key, gatewayID string, embeddingData *Embedding, data []byte) error
	Search(ctx context.Context, index, query string, embeddingData *Embedding) ([]SearchResult, error)
}

type SearchResult

type SearchResult struct {
	Key   string
	Score float64
	Data  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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