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 ¶
- Variables
- type Client
- func (c Client) Dimensions(ctx context.Context) (int, error)
- func (c Client) EmbedDocuments(ctx context.Context, docs []*document.Document) ([][]float64, error)
- func (c Client) EmbedText(ctx context.Context, text string) ([]float64, error)
- func (c Client) EmbedTexts(ctx context.Context, texts []string) ([][]float64, error)
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 (Client) EmbedDocuments ¶
Click to show internal directories.
Click to hide internal directories.