fastapi

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(serverURL string, opts ...Option) (embeddings.Embedder, error)

New creates a new FastAPI embedder client.

Types

type Embedder

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

Embedder communicates with a remote FastAPI server to generate embeddings. It directly implements the embeddings.Embedder interface.

func (*Embedder) EmbedDocuments

func (e *Embedder) EmbedDocuments(ctx context.Context, texts []string) ([][]float32, error)

EmbedDocuments sends a batch of documents to the FastAPI server for embedding.

func (*Embedder) EmbedQueries

func (e *Embedder) EmbedQueries(ctx context.Context, texts []string) ([][]float32, error)

EmbedQueries embeds a batch of queries.

func (*Embedder) EmbedQuery

func (e *Embedder) EmbedQuery(ctx context.Context, text string) ([]float32, error)

EmbedQuery embeds a single query.

func (*Embedder) GetDimension

func (e *Embedder) GetDimension(ctx context.Context) (int, error)

GetDimension lazily fetches the embedding dimension by sending a test query.

type Option

type Option func(*options)

Option defines a function type for configuring the embedder.

func WithAPIKey

func WithAPIKey(key string) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient allows providing a custom http.Client.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets a custom logger.

func WithTask

func WithTask(task string) Option

WithTask allows overriding the default task description sent to the API.

Jump to

Keyboard shortcuts

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