Documentation
¶
Index ¶
- Constants
- Variables
- func BuildGraph(task AgentTask) workflow.Graph
- type AgentTask
- type AgentTaskStructured
- type AsyncResult
- type Client
- func (c *Client) AvailableFor(mediaType string) []string
- func (c *Client) DryRun(engineName string, task AgentTask) (engine.DryRunResult, error)
- func (c *Client) EngineCapabilities(name string) (engine.Capability, error)
- func (c *Client) EngineNames() []string
- func (c *Client) Execute(ctx context.Context, engineName string, graph workflow.Graph, ...) (Result, error)
- func (c *Client) ExecuteAsync(ctx context.Context, engineName string, graph workflow.Graph) <-chan AsyncResult
- func (c *Client) ExecutePipeline(ctx context.Context, p *Pipeline) ([]Result, error)
- func (c *Client) ExecutePrompt(ctx context.Context, engineName string, prompt string) (Result, error)
- func (c *Client) ExecutePromptAuto(ctx context.Context, selector Selector, prompt string) (RoutedResult, error)
- func (c *Client) ExecuteTask(ctx context.Context, engineName string, task AgentTask, opts ...ExecuteOption) (Result, error)
- func (c *Client) ExecuteTaskAuto(ctx context.Context, selector Selector, task AgentTask) (RoutedResult, error)
- func (c *Client) ExecuteTaskWithFallback(ctx context.Context, engines []string, task AgentTask, opts ...ExecuteOption) (FallbackResult, error)
- func (c *Client) ExecuteWithFallback(ctx context.Context, engines []string, graph workflow.Graph, ...) (FallbackResult, error)
- func (c *Client) ExecuteWithHint(ctx context.Context, engineName string, graph workflow.Graph) (OutputHint, error)deprecated
- func (c *Client) RegisterEngine(name string, e engine.Engine) error
- func (c *Client) Use(mw ...Middleware)
- type ExecuteOption
- type FallbackError
- type FallbackResult
- type Middleware
- type OutputHintdeprecated
- type OutputKind
- type Pipeline
- type PipelineStep
- type ProgressEvent
- type ReferenceAsset
- type ReferenceType
- type Result
- type RoutedResult
- type Selection
- type Selector
- type TTSOptions
- type VoiceDesignOptions
Constants ¶
const ( OutputUnknown = engine.OutputUnknown OutputURL = engine.OutputURL OutputDataURI = engine.OutputDataURI OutputJSON = engine.OutputJSON OutputPlainText = engine.OutputPlainText )
Variables ¶
Functions ¶
func BuildGraph ¶
BuildGraph compiles a high-level agent task into the SDK's workflow graph format.
Types ¶
type AgentTask ¶
type AgentTask struct {
Prompt string
NegativePrompt string
Width int
Height int
Size string
Duration int
Watermark *bool
References []ReferenceAsset
TTS *TTSOptions
VoiceDesign *VoiceDesignOptions
// Structured groups image/video options separately for finer control.
Structured *AgentTaskStructured
}
AgentTask is a graph-free request shape for agents.
type AgentTaskStructured ¶
type AgentTaskStructured struct {
ImageSize string
ImageWatermark *bool
VideoDuration int
VideoSize string
VideoWatermark *bool
VideoAspectRatio string
VideoResolution string // "480P", "720P", "1080P"
VideoAudio *bool
}
AgentTaskStructured 将图像与视频选项分组;便于扩展而无需继续增大 AgentTask 扁平字段。
type AsyncResult ¶
AsyncResult delivers an asynchronous execution outcome.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client routes a workflow graph to a registered execution engine.
func (*Client) AvailableFor ¶
AvailableFor returns registered engine names whose capabilities include the given media type. Engines that do not implement Describer are included (assumed capable).
func (*Client) DryRun ¶
DryRun checks what would happen without actually executing the task. Returns an estimation if the engine implements DryRunner; otherwise returns a basic result based on Describer capabilities.
func (*Client) EngineCapabilities ¶
func (c *Client) EngineCapabilities(name string) (engine.Capability, error)
EngineCapabilities returns the capabilities of a registered engine. If the engine does not implement Describer, an empty Capability is returned.
func (*Client) EngineNames ¶
EngineNames returns registered engine names in deterministic order.
func (*Client) Execute ¶
func (c *Client) Execute(ctx context.Context, engineName string, graph workflow.Graph, opts ...ExecuteOption) (Result, error)
Execute dispatches the graph to the named engine.
func (*Client) ExecuteAsync ¶
func (c *Client) ExecuteAsync(ctx context.Context, engineName string, graph workflow.Graph) <-chan AsyncResult
ExecuteAsync runs Execute in a goroutine and delivers the result on the returned channel. The channel is closed after sending exactly one value. Cancelling ctx stops the work.
func (*Client) ExecutePipeline ¶
ExecutePipeline runs each step in sequence, feeding results forward.
func (*Client) ExecutePrompt ¶
func (c *Client) ExecutePrompt(ctx context.Context, engineName string, prompt string) (Result, error)
ExecutePrompt runs the simplest agent request: a single prompt.
func (*Client) ExecutePromptAuto ¶
func (c *Client) ExecutePromptAuto(ctx context.Context, selector Selector, prompt string) (RoutedResult, error)
ExecutePromptAuto lets a selector choose the engine for a prompt-driven request.
func (*Client) ExecuteTask ¶
func (c *Client) ExecuteTask(ctx context.Context, engineName string, task AgentTask, opts ...ExecuteOption) (Result, error)
ExecuteTask converts an agent task into a workflow graph and routes it to the target engine.
func (*Client) ExecuteTaskAuto ¶
func (c *Client) ExecuteTaskAuto(ctx context.Context, selector Selector, task AgentTask) (RoutedResult, error)
ExecuteTaskAuto lets a selector choose the engine for a structured agent task.
func (*Client) ExecuteTaskWithFallback ¶
func (c *Client) ExecuteTaskWithFallback(ctx context.Context, engines []string, task AgentTask, opts ...ExecuteOption) (FallbackResult, error)
ExecuteTaskWithFallback is the AgentTask variant of ExecuteWithFallback.
func (*Client) ExecuteWithFallback ¶
func (c *Client) ExecuteWithFallback(ctx context.Context, engines []string, graph workflow.Graph, opts ...ExecuteOption) (FallbackResult, error)
ExecuteWithFallback tries each engine in order; the first success wins. All engines that fail are recorded in FallbackResult.Skipped.
func (*Client) ExecuteWithHint
deprecated
func (*Client) RegisterEngine ¶
RegisterEngine registers an engine under a logical name.
func (*Client) Use ¶
func (c *Client) Use(mw ...Middleware)
Use appends middleware that wraps every engine on each Execute call. Middleware is applied in the order added (first added = outermost wrapper).
type ExecuteOption ¶
type ExecuteOption func(*executeConfig)
ExecuteOption configures optional Execute behavior.
func WithProgress ¶
func WithProgress(fn func(ProgressEvent)) ExecuteOption
WithProgress registers a callback for execution progress events.
type FallbackError ¶
FallbackError records a single engine failure during fallback execution.
func (FallbackError) Error ¶
func (e FallbackError) Error() string
func (FallbackError) Unwrap ¶
func (e FallbackError) Unwrap() error
type FallbackResult ¶
type FallbackResult struct {
Engine string
Output Result
Skipped []FallbackError
}
FallbackResult is the outcome of a fallback-enabled execution.
type Middleware ¶
Middleware wraps an engine to add cross-cutting behavior (logging, timing, retry, etc.).
func WithLogging ¶
func WithLogging(w io.Writer) Middleware
WithLogging returns middleware that logs engine calls to the given writer.
func WithRetry ¶
func WithRetry(maxRetries int) Middleware
WithRetry returns middleware that retries on retryable errors up to maxRetries times.
type OutputHint
deprecated
type OutputHint struct {
Kind OutputKind
Raw string
}
OutputHint 包含原始输出与 InterpretOutputKind 的推断类别。
Deprecated: Use Result instead; Execute now returns Result with Kind populated.
type OutputKind ¶
type OutputKind = engine.OutputKind
OutputKind is an alias for engine.OutputKind.
func InterpretOutputKind ¶
func InterpretOutputKind(s string) OutputKind
InterpretOutputKind 根据内容前缀与 JSON 合法性做轻量分类;任务 id、纯数字等会落在 OutputPlainText。
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline chains multiple engine executions where each step's input depends on the previous output.
func NewPipeline ¶
NewPipeline starts a pipeline with an initial engine and task.
func (*Pipeline) Then ¶
func (p *Pipeline) Then(fn PipelineStep) *Pipeline
Then appends a step that transforms the previous result into the next task.
type PipelineStep ¶
PipelineStep transforms a previous result into the next task and target engine.
type ProgressEvent ¶
type ProgressEvent struct {
Phase string // "submitted", "polling", "completed"
Attempt int // poll attempt number (0 for non-polling phases)
Elapsed time.Duration // wall-clock time since execution start
}
ProgressEvent reports execution progress to the caller.
type ReferenceAsset ¶
type ReferenceAsset struct {
Type ReferenceType
URL string
}
ReferenceAsset describes an externally reachable media input.
type ReferenceType ¶
type ReferenceType string
ReferenceType identifies the kind of remote asset to attach to an agent task.
const ( ReferenceTypeImage ReferenceType = "image" ReferenceTypeVideo ReferenceType = "video" )
type Result ¶
type Result struct {
Value string // Raw output from the engine.
Kind OutputKind // Authoritative classification from the engine.
Engine string // Name of the engine that produced the result.
Elapsed time.Duration // Wall-clock execution time.
Metadata map[string]any // Engine-specific data (optional).
}
Result is the public outcome of every Client execution method.
type RoutedResult ¶
RoutedResult is the result of a selector-driven execution.
type Selector ¶
type Selector interface {
SelectEngine(ctx context.Context, task AgentTask, engines []string) (Selection, error)
}
Selector decides which registered engine should handle a task.
Directories
¶
| Path | Synopsis |
|---|---|
|
aigoerr
Package aigoerr provides structured, classifiable errors for aigo engines.
|
Package aigoerr provides structured, classifiable errors for aigo engines. |
|
aliyun
Package aliyun 对接阿里云百炼(DashScope)多模态 API。
|
Package aliyun 对接阿里云百炼(DashScope)多模态 API。 |
|
aliyun/internal/async
Package async 封装百炼异步任务创建与轮询(图生图、文生视频等共用)。
|
Package async 封装百炼异步任务创建与轮询(图生图、文生视频等共用)。 |
|
aliyun/internal/audiogen
Package audiogen 实现阿里云百炼「语音合成 / 声音设计」类能力。
|
Package audiogen 实现阿里云百炼「语音合成 / 声音设计」类能力。 |
|
aliyun/internal/graphx
Package graphx 从 workflow.Graph 抽取各域(图/视频/音频)共用字段。
|
Package graphx 从 workflow.Graph 抽取各域(图/视频/音频)共用字段。 |
|
aliyun/internal/imggen
Package imggen 实现阿里云百炼「图片生成」类能力(文生图等)。
|
Package imggen 实现阿里云百炼「图片生成」类能力(文生图等)。 |
|
aliyun/internal/vidgen
Package vidgen 实现阿里云百炼「视频生成 / 编辑」类能力(Wan 系列异步接口)。
|
Package vidgen 实现阿里云百炼「视频生成 / 编辑」类能力(Wan 系列异步接口)。 |
|
ark
Package ark implements the Volcengine Ark (火山方舟) video generation engine, supporting Seedance 2.0 and other Ark content generation models.
|
Package ark implements the Volcengine Ark (火山方舟) video generation engine, supporting Seedance 2.0 and other Ark content generation models. |
|
embed
Package embed defines the EmbedEngine interface for vector embedding backends.
|
Package embed defines the EmbedEngine interface for vector embedding backends. |
|
embed/aliyun
Package aliyun implements the Alibaba Cloud DashScope (Bailian) embedding backend.
|
Package aliyun implements the Alibaba Cloud DashScope (Bailian) embedding backend. |
|
embed/gemini
Package gemini implements the Gemini Embedding 2 backend.
|
Package gemini implements the Gemini Embedding 2 backend. |
|
embed/jina
Package jina implements the Jina AI embedding backend.
|
Package jina implements the Jina AI embedding backend. |
|
embed/openai
Package openai implements the OpenAI text embedding backend.
|
Package openai implements the OpenAI text embedding backend. |
|
embed/voyage
Package voyage implements the Voyage AI embedding backend.
|
Package voyage implements the Voyage AI embedding backend. |
|
httpx
Package httpx 提供各引擎共用的 HTTP Client 默认值(超时等)。
|
Package httpx 提供各引擎共用的 HTTP Client 默认值(超时等)。 |
|
newapi
Package newapi 对接 New API 文档中的大模型 HTTP 接口(图像 / 视频 / 语音等)。
|
Package newapi 对接 New API 文档中的大模型 HTTP 接口(图像 / 视频 / 语音等)。 |
|
newapi/internal/rt
Package rt 提供网关 BaseURL 规范化与路径拼接。
|
Package rt 提供网关 BaseURL 规范化与路径拼接。 |
|
examples
|
|
|
agent_auto_router
command
|
|
|
aliyun_qwen_image
command
|
|
|
aliyun_qwen_tts
command
|
|
|
aliyun_qwen_voice_design
command
|
|
|
aliyun_wan_image
command
|
|
|
aliyun_wan_r2v
command
|
|
|
aliyun_wan_t2v
command
|
|
|
aliyun_wan_videoedit
command
|
|
|
aliyun_zimage
command
|
|
|
newapi_image
command
|
|
|
newapi_seedance_video
command
|
|
|
newapi_speech
command
|
|
|
newapi_video
command
|
|
|
Package tooldef provides JSON Schema tool definitions for AI agent frameworks.
|
Package tooldef provides JSON Schema tool definitions for AI agent frameworks. |