embeddingclient

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package embeddingclient projects validated Core embedding responses into independently owned single or batch vectors.

Example
package main

import (
	"context"
	"fmt"

	"github.com/Tangerg/scope/core/embedding"
	"github.com/Tangerg/scope/core/embeddingclient"
)

func main() {
	model := embedding.ModelFunc(func(context.Context, *embedding.Request) (*embedding.Response, error) {
		output, _ := embedding.NewOutput([]float64{0.1, 0.2}, nil)
		return embedding.NewResponse([]*embedding.Output{output}, &embedding.ResponseMetadata{})
	})
	client, err := embeddingclient.New(model)
	if err != nil {
		panic(err)
	}
	vector, err := client.EmbedText(context.Background(), "scope")
	if err != nil {
		panic(err)
	}
	fmt.Println(len(vector))
}
Output:
2

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNilModel = errors.New("embeddingclient: nil model")

Functions

This section is empty.

Types

type Client

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

Client is an immutable, concurrency-safe projection of embedding.Model for callers that need vectors rather than protocol responses. It validates both model boundaries, preserves input order, and returns independently owned vectors. Provider metadata remains available only through the model.

func New

func New(model embedding.Model) (Client, error)

New takes no configuration because this client adds no policy: it projects embedding.Model to plain vectors for callers that do not need protocol metadata. Defaults, middleware, and options stay with the model that owns them.

func (Client) EmbedText

func (c Client) EmbedText(ctx context.Context, text string) ([]float64, error)

EmbedText embeds one text without exposing batch cardinality to a caller that has exactly one input.

func (Client) EmbedTexts

func (c Client) EmbedTexts(ctx context.Context, texts []string) ([][]float64, error)

Jump to

Keyboard shortcuts

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