embedding

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPClientTimeout = 60 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddingData

type EmbeddingData struct {
	Embedding []float64 `json:"embedding"`
}

EmbeddingData is a single embedding entry in the API response.

type EmbeddingGenerator

type EmbeddingGenerator interface {
	GenerateEmbeddings(ctx context.Context, inputs []string, encodingFormat string) (*EmbeddingResult, error)
}

type EmbeddingRequest

type EmbeddingRequest struct {
	Model          string   `json:"model"`
	Input          []string `json:"input"`
	EncodingFormat string   `json:"encoding_format,omitempty"`
}

EmbeddingRequest is the JSON body for the embedding API (OpenAI-compatible).

type EmbeddingResponse

type EmbeddingResponse struct {
	Data []EmbeddingData `json:"data"`
}

EmbeddingResponse is the JSON response from the embedding API.

type EmbeddingResult

type EmbeddingResult struct {
	Embeddings [][]float64
	Count      int
}

EmbeddingResult holds the embedding vectors and count returned by GenerateEmbeddings.

type HTTPClient

type HTTPClient struct {
	Client *http.Client
	Config *HTTPClientConfig
}

func NewHTTPClient

func NewHTTPClient(config *HTTPClientConfig) *HTTPClient

func (*HTTPClient) GenerateEmbeddings

func (c *HTTPClient) GenerateEmbeddings(
	ctx context.Context, inputs []string, encodingFormat string,
) (*EmbeddingResult, error)

type HTTPClientConfig

type HTTPClientConfig struct {
	Endpoint   string
	AuthFormat string
	APIKey     string
	ModelName  string
}

HTTPClientConfig configures the HTTP embedding client.

Jump to

Keyboard shortcuts

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