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 ¶
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.
Click to show internal directories.
Click to hide internal directories.