embed

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package embed provides client functionality for the xAI Embeddings API.

Index

Constants

This section is empty.

Variables

View Source
var ErrClientNotInitialized = errors.New("embed client not initialized: REST client is nil")

ErrClientNotInitialized is returned when the REST client is not initialized.

Functions

This section is empty.

Types

type Client

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

Client provides access to the xAI Embeddings API.

func NewClient

func NewClient(restClient *rest.Client) *Client

NewClient creates a new embeddings client.

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, req *Request) (*Response, error)

Generate generates embeddings for the given request.

type Embedding

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

Embedding represents a single embedding result.

func (*Embedding) Index

func (e *Embedding) Index() int32

Index returns the index of this embedding.

func (*Embedding) Proto

func (e *Embedding) Proto() *xaiv1.Embedding

Proto returns the underlying protobuf embedding.

func (*Embedding) Vectors

func (e *Embedding) Vectors() []FeatureVector

Vectors returns the feature vectors for this embedding.

type FeatureVector

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

FeatureVector represents an embedding vector.

func (*FeatureVector) Base64Array

func (f *FeatureVector) Base64Array() string

Base64Array returns the embedding as a base64-encoded string.

func (*FeatureVector) FloatArray

func (f *FeatureVector) FloatArray() []float32

FloatArray returns the embedding as a float array.

func (*FeatureVector) Proto

func (f *FeatureVector) Proto() *xaiv1.FeatureVector

Proto returns the underlying protobuf feature vector.

type Input

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

Input represents an embedding input (text or image).

func Image

func Image(imageURL string, detail xaiv1.ImageDetail) Input

Image creates an image input for embedding.

func Text

func Text(text string) Input

Text creates a text input for embedding.

func (Input) Proto

func (i Input) Proto() *xaiv1.EmbedInput

Proto returns the underlying protobuf input.

type Request

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

Request represents an embeddings request.

func NewRequest

func NewRequest(model string, inputs ...Input) *Request

NewRequest creates a new embeddings request.

func (*Request) Proto

func (r *Request) Proto() *xaiv1.EmbedRequest

Proto returns the underlying protobuf request.

func (*Request) WithEncodingFormat

func (r *Request) WithEncodingFormat(format xaiv1.EmbedEncodingFormat) *Request

WithEncodingFormat sets the encoding format for the embeddings.

func (*Request) WithUser

func (r *Request) WithUser(user string) *Request

WithUser sets the user identifier for the request.

type Response

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

Response represents an embeddings response.

func (*Response) Embeddings

func (r *Response) Embeddings() []Embedding

Embeddings returns all embeddings in the response.

func (*Response) ID

func (r *Response) ID() string

ID returns the response ID.

func (*Response) Model

func (r *Response) Model() string

Model returns the model used.

func (*Response) Proto

func (r *Response) Proto() *xaiv1.EmbedResponse

Proto returns the underlying protobuf response.

func (*Response) SystemFingerprint

func (r *Response) SystemFingerprint() string

SystemFingerprint returns the system fingerprint.

func (*Response) Usage

func (r *Response) Usage() *xaiv1.EmbeddingUsage

Usage returns the usage information.

Jump to

Keyboard shortcuts

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