weaviate

package
v1.38.3 Latest Latest
Warning

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

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

Documentation

Overview

Package weaviate provides an adapter for generating embeddings via Zerfoo's OpenAI-compatible HTTP API and inserting them into a Weaviate vector database client.

The adapter does not import the Weaviate Go client directly. It produces []float32 embedding vectors from text using Zerfoo's /v1/embeddings endpoint. Callers can then pass those vectors to Weaviate's batch import or search API.

Usage:

emb := weaviate.NewAdapter("http://localhost:8080", "nomic-embed-text")
vecs, err := emb.EmbedDocuments(ctx, []string{"doc one", "doc two"})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {

	// BatchSize controls how many texts are sent per API request. Default 32.
	BatchSize int
	// contains filtered or unexported fields
}

Adapter wraps Zerfoo's /v1/embeddings endpoint and produces float32 vectors suitable for insertion into Weaviate.

func NewAdapter

func NewAdapter(baseURL, model string, opts ...AdapterOption) *Adapter

NewAdapter creates an Adapter pointing at a running Zerfoo serve instance.

baseURL is the server root (e.g. "http://localhost:8080"). model is the embedding model identifier forwarded in the request body.

func (*Adapter) EmbedDocuments

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

EmbedDocuments embeds multiple texts and returns one vector per text. Texts are sent in batches of BatchSize to avoid oversized requests. This mirrors the LangChain-Go schema.Embedder.EmbedDocuments signature.

func (*Adapter) EmbedQuery

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

EmbedQuery embeds a single query string and returns its vector. This mirrors the LangChain-Go schema.Embedder.EmbedQuery signature.

type AdapterOption

type AdapterOption func(*Adapter)

AdapterOption configures an Adapter.

func WithBatchSize

func WithBatchSize(n int) AdapterOption

WithBatchSize sets the number of texts to embed in a single request.

func WithHTTPClient

func WithHTTPClient(c *http.Client) AdapterOption

WithHTTPClient replaces the default HTTP client.

Jump to

Keyboard shortcuts

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