Documentation
¶
Overview ¶
Package embed provides client functionality for the xAI Embeddings API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
type Embedding ¶
type Embedding struct {
// contains filtered or unexported fields
}
Embedding represents a single embedding result.
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 (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 ¶
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.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response represents an embeddings response.
func (*Response) Embeddings ¶
Embeddings returns all embeddings in the response.
func (*Response) Proto ¶
func (r *Response) Proto() *xaiv1.EmbedResponse
Proto returns the underlying protobuf response.
func (*Response) SystemFingerprint ¶
SystemFingerprint returns the system fingerprint.
func (*Response) Usage ¶
func (r *Response) Usage() *xaiv1.EmbeddingUsage
Usage returns the usage information.