dashscopeembeddings

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Overview

Package dashscopeembeddings implements Alibaba Model Studio's native multimodal embedding shape: input.contents, parameters.dimension, and results under output.embeddings.

Only the multimodal models use it. DashScope's text embeddings are served on the OpenAI-compatible endpoint, which is why the vendor's default protocol is the OpenAI one and the multimodal entries override it.

https://help.aliyun.com/zh/model-studio/multimodal-embedding-api-reference

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks DashScope's native multimodal embedding to one endpoint.

func New

func New(cfg Config) *Client

New builds a client.

func (*Client) AcceptsImages

func (c *Client) AcceptsImages() bool

AcceptsImages is always true: the image part is part of the schema.

func (*Client) BuildImageRequestBody

func (c *Client) BuildImageRequestBody(images []api.EmbedImage, _ api.EmbedInputType) map[string]any

BuildImageRequestBody is the golden-test entry point for images. Each content is {"image": URL or "data:image/{format};base64,{data}"}.

func (*Client) BuildRequestBody

func (c *Client) BuildRequestBody(texts []string, _ api.EmbedInputType) map[string]any

BuildRequestBody is the golden-test entry point.

func (*Client) Embed

func (c *Client) Embed(
	ctx context.Context, texts []string, kind api.EmbedInputType,
) ([][]float32, error)

Embed vectorizes one batch.

func (*Client) EmbedImages

func (c *Client) EmbedImages(
	ctx context.Context, images []api.EmbedImage, kind api.EmbedInputType,
) ([][]float32, error)

EmbedImages vectorizes one batch of images, each its own vector.

type Config

type Config struct {
	Endpoint   api.Endpoint
	Settings   api.EmbeddingsSettings
	Dimensions int
	Retry      api.RetryPolicy
}

Config is everything the client needs, already resolved by the api.

Jump to

Keyboard shortcuts

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