embeddingclient

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package embeddingclient provides direct conveniences around Core embedding models for callers that only need 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. Dimensions deliberately probes once per call instead of hiding a cache lifetime; provider metadata remains available only through the model.

func New

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

func (Client) Dimensions

func (c Client) Dimensions(ctx context.Context) (int, error)

func (Client) EmbedDocuments

func (c Client) EmbedDocuments(ctx context.Context, docs []*document.Document) ([][]float64, 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