embeddingclient

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 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 validates both model boundaries, preserves input order, and returns independently owned vectors. It is immutable; concurrent use requires a concurrency-safe Model. Provider metadata remains available through the model.

func New

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

func (Client) EmbedText

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

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