Documentation
¶
Overview ¶
Package embed defines the EmbedEngine interface for vector embedding backends.
Unlike the generation-oriented engine.Engine (workflow.Graph → Result), EmbedEngine converts raw content (text, image bytes, video bytes) into dense float32 vectors suitable for similarity search.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capability ¶
type Capability struct {
// SupportedTypes lists content types this engine can embed.
SupportedTypes []ContentType
// Models lists available model identifiers.
Models []string
// MaxDimensions is the maximum output dimensionality.
MaxDimensions int
// SupportsMRL indicates Matryoshka Representation Learning support
// (embeddings can be truncated to fewer dimensions).
SupportsMRL bool
}
Capability describes what an embedding engine supports.
type ContentType ¶
type ContentType int
ContentType identifies the kind of content being embedded.
const ( ContentText ContentType = iota // plain text ContentImage // image bytes (JPEG, PNG, WebP) ContentVideo // video bytes (MP4, MOV) )
type Describer ¶
type Describer interface {
EmbedCapabilities() Capability
}
Describer is an optional interface for engines that advertise capabilities.
type EmbedEngine ¶
type EmbedEngine interface {
// Embed produces a vector for the given request.
Embed(ctx context.Context, req Request) (Result, error)
// EmbedBatch produces vectors for multiple requests.
// Backends that support batch APIs can implement this efficiently;
// the default implementation calls Embed sequentially.
EmbedBatch(ctx context.Context, reqs []Request) ([]Result, error)
// Dimensions returns the output vector dimensionality.
Dimensions() int
}
EmbedEngine converts content into vector embeddings.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a sliding-window rate limiter. Shared by all embedding backends that need request throttling.
func NewRateLimiter ¶
func NewRateLimiter(maxPerMinute int) *RateLimiter
NewRateLimiter creates a rate limiter allowing max requests per minute.
type Request ¶
type Request struct {
// Content holds the raw data: a string for text, or []byte for image/video.
Content any
// Type classifies the content.
Type ContentType
// TaskType hints how the embedding will be used (e.g., "RETRIEVAL_DOCUMENT",
// "RETRIEVAL_QUERY"). Backends that support task-type-aware embedding
// (Gemini, Voyage) use this; others ignore it.
TaskType string
}
Request describes what to embed.
func ImageRequest ¶
ImageRequest is a convenience constructor for image embedding.
func TextRequest ¶
TextRequest is a convenience constructor for text embedding.
func VideoRequest ¶
VideoRequest is a convenience constructor for video embedding.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package aliyun implements the Alibaba Cloud DashScope (Bailian) embedding backend.
|
Package aliyun implements the Alibaba Cloud DashScope (Bailian) embedding backend. |
|
Package gemini implements the Gemini Embedding 2 backend.
|
Package gemini implements the Gemini Embedding 2 backend. |
|
Package jina implements the Jina AI embedding backend.
|
Package jina implements the Jina AI embedding backend. |
|
Package openai implements the OpenAI text embedding backend.
|
Package openai implements the OpenAI text embedding backend. |
|
Package voyage implements the Voyage AI embedding backend.
|
Package voyage implements the Voyage AI embedding backend. |