embeddings

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEmbeddingsEndpoint is the default AINative platform embeddings API endpoint
	DefaultEmbeddingsEndpoint = "https://api.ainative.io/api/v1/embeddings"

	// DefaultTimeout for embeddings requests
	DefaultTimeout = 30 * time.Second

	// MaxBatchSize is the maximum number of texts to embed in a single request
	MaxBatchSize = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AINativeEmbeddingsClient

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

AINativeEmbeddingsClient provides access to AINative platform embeddings API This is the ONLY way to get embeddings - we do NOT use OpenAI embeddings endpoints

func NewAINativeEmbeddingsClient

func NewAINativeEmbeddingsClient(config Config) (*AINativeEmbeddingsClient, error)

NewAINativeEmbeddingsClient creates a new AINative embeddings client

func (*AINativeEmbeddingsClient) Close

func (c *AINativeEmbeddingsClient) Close() error

Close releases any resources held by the client

func (*AINativeEmbeddingsClient) Embed

func (c *AINativeEmbeddingsClient) Embed(ctx context.Context, texts []string, model string) (*EmbeddingResult, error)

Embed generates embeddings for the given texts using AINative platform API This is the primary method for obtaining vector embeddings

type Config

type Config struct {
	APIKey     string                 // Required: AINative API key
	Endpoint   string                 // Optional: Custom endpoint (defaults to DefaultEmbeddingsEndpoint)
	HTTPClient *http.Client           // Optional: Custom HTTP client
	Logger     logger.LoggerInterface // Optional: Logger for debugging
	MaxRetries int                    // Optional: Max retry attempts (default: 3)
	RetryDelay time.Duration          // Optional: Delay between retries (default: 1s)
}

Config contains configuration for the AINative embeddings client

type EmbeddingAPIError

type EmbeddingAPIError struct {
	StatusCode int
	Message    string
	Type       string
	Code       string
}

EmbeddingAPIError represents an error from the embeddings API

func (*EmbeddingAPIError) Error

func (e *EmbeddingAPIError) Error() string

func (*EmbeddingAPIError) IsAuthenticationError

func (e *EmbeddingAPIError) IsAuthenticationError() bool

IsAuthenticationError returns true if the error is due to authentication failure

func (*EmbeddingAPIError) IsQuotaExceededError

func (e *EmbeddingAPIError) IsQuotaExceededError() bool

IsQuotaExceededError returns true if the error is due to quota exhaustion

func (*EmbeddingAPIError) IsRateLimitError

func (e *EmbeddingAPIError) IsRateLimitError() bool

IsRateLimitError returns true if the error is due to rate limiting

type EmbeddingResult

type EmbeddingResult struct {
	Embeddings  [][]float32 // Vector embeddings (one per input text)
	Model       string      // Model used for embedding
	TotalTokens int         // Total tokens processed
}

EmbeddingResult contains the results of an embedding operation

Jump to

Keyboard shortcuts

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