alibaba

package module
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package alibaba wraps Alibaba Cloud's DashScope model platform, which hosts the Qwen / Tongyi family and several other Alibaba models.

DashScope exposes two surfaces:

  • the native /api/v1/services/aigc/text-generation/generation endpoint with a DashScope-specific JSON shape (not used here);
  • the /compatible-mode/v1 path which speaks the OpenAI chat-completions / embeddings spec.

This package uses the compatible-mode endpoint to route through the openai provider facade. DashScope-specific knobs (enable_thinking, enable_search, web search citations, etc.) use the namespaced OpenAI request extension.

See https://help.aliyun.com/zh/model-studio/ for the docs.

Index

Constants

View Source
const (
	OpenAIRequestExtensionKey     = "alibaba/openai_request"
	OpenAIResponseExtensionKey    = "alibaba/openai_response"
	OpenAIStreamChunkExtensionKey = "alibaba/openai_stream_chunk"
)

Namespacing preserves provider-specific data without promoting it into the shared Core protocol or colliding with another provider.

View Source
const (
	// BaseURLChina is the domestic DashScope OpenAI-compat endpoint.
	BaseURLChina = "https://dashscope.aliyuncs.com/compatible-mode/v1"

	// BaseURLIntl is the Singapore DashScope OpenAI-compat endpoint —
	// required for international (non-mainland-China) users.
	BaseURLIntl = "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
)
View Source
const (
	ModelQwen37Max   = "qwen3.7-max"
	ModelQwen37Plus  = "qwen3.7-plus"
	ModelQwen36Plus  = "qwen3.6-plus"
	ModelQwen36Flash = "qwen3.6-flash"

	// ModelQwen3CoderPlus (qwen3-coder-plus) targets code generation
	// / completion / repair.
	ModelQwen3CoderPlus = "qwen3-coder-plus"
)

Current chat model ids. The Qwen family is versioned aggressively; the constants below intentionally name rolling production aliases. See https://help.aliyun.com/zh/model-studio/getting-started/models for the live catalog.

View Source
const (
	// ModelEmbeddingV4 (text-embedding-v4) is the current general-purpose
	// embedding model.
	ModelEmbeddingV4 = "text-embedding-v4"
)

Embedding model ids.

View Source
const (
	Provider = "Alibaba"
)

Provider is the stable backend name for host-side attribution.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat added in v0.13.0

type Chat = openai.ChatCompletions

Chat implements DashScope's chat endpoint.

func NewChat added in v0.13.0

func NewChat(config ChatConfig) (*Chat, error)

NewChat rejects an invalid provider binding before the first chat call.

type ChatConfig added in v0.13.0

type ChatConfig struct {
	APIKey         string
	DefaultOptions corechat.Options
	BaseURL        string
	HTTPClient     *http.Client
}

ChatConfig binds provider access and defaults shared by every chat call.

func (ChatConfig) Validate added in v0.13.0

func (c ChatConfig) Validate() error

type EmbeddingModel

type EmbeddingModel = openai.EmbeddingModel

EmbeddingModel is the shared protocol type itself rather than a wrapper, so this provider adds no second public surface for callers to choose between.

func NewEmbeddingModel

func NewEmbeddingModel(config EmbeddingModelConfig) (*EmbeddingModel, error)

NewEmbeddingModel rejects an invalid provider binding before the first embedding call.

type EmbeddingModelConfig

type EmbeddingModelConfig struct {
	APIKey         string
	DefaultOptions embedding.Options
	BaseURL        string
	HTTPClient     *http.Client
}

EmbeddingModelConfig binds provider access and defaults shared by every embedding call.

func (EmbeddingModelConfig) Validate

func (e EmbeddingModelConfig) Validate() error

Jump to

Keyboard shortcuts

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