embedding

package
v0.0.0-...-30b4b00 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	Model      string
	MaxRetries int
	RetryDelay time.Duration
}

Config holds embedding service configuration

type EmbeddingResponse

type EmbeddingResponse struct {
	Object string `json:"object"`
	Data   []struct {
		Object    string    `json:"object"`
		Index     int       `json:"index"`
		Embedding []float32 `json:"embedding"`
	} `json:"data"`
	Model string `json:"model"`
	Usage struct {
		PromptTokens int `json:"prompt_tokens"`
		TotalTokens  int `json:"total_tokens"`
	} `json:"usage"`
}

EmbeddingResponse represents OpenAI embedding API response

type EmbeddingService

type EmbeddingService struct {
	// contains filtered or unexported fields
}

EmbeddingService provides text embedding generation

func DefaultService

func DefaultService() *EmbeddingService

DefaultService returns default embedding service using system config

func NewEmbeddingService

func NewEmbeddingService(cfg Config) *EmbeddingService

NewEmbeddingService creates a new embedding service

func NewServiceFromChannel

func NewServiceFromChannel(channel *model.Channel) (*EmbeddingService, error)

NewServiceFromChannel creates an EmbeddingService from a Channel

func (*EmbeddingService) GetEmbedding

func (s *EmbeddingService) GetEmbedding(ctx context.Context, text string) ([]float32, error)

GetEmbedding generates embedding for a single text

func (*EmbeddingService) GetEmbeddings

func (s *EmbeddingService) GetEmbeddings(ctx context.Context, texts []string) ([][]float32, error)

GetEmbeddings generates embeddings for multiple texts

Jump to

Keyboard shortcuts

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