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) RecoverPending() ([]TaskRecord, error)
- func (c *Client) RegisterEngine(name string, e engine.Engine) error
- func (c *Client) Resume(ctx context.Context, taskID string) (Result, error)
- func (c *Client) Submit(ctx context.Context, engineName string, graph workflow.Graph, ...) (string, error)
- func (c *Client) Use(mw ...Middleware)
- type ClientOption
- type ExecuteOption
- type FallbackError
- type FallbackResult
- type FileTaskStore
- type Middleware
- type MusicOptions
- type OutputKind
- type Pipeline
- type PipelineStep
- type ProgressEvent
- type ReferenceAsset
- type ReferenceType
- type Result
- type RoutedResult
- type Selection
- type Selector
- type TTSOptions
- type TaskRecord
- type TaskStore
- type VoiceDesignOptions
Constants ¶
const ( OutputUnknown = engine.OutputUnknown OutputURL = engine.OutputURL OutputDataURI = engine.OutputDataURI OutputJSON = engine.OutputJSON OutputPlainText = engine.OutputPlainText )
const ( TaskStatusPending = "pending" TaskStatusCompleted = "completed" TaskStatusFailed = "failed" )
TaskStatus constants.
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
Music *MusicOptions
// 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) RecoverPending ¶ added in v0.11.0
func (c *Client) RecoverPending() ([]TaskRecord, error)
RecoverPending returns all tasks that are still pending (not completed or failed). Callers should iterate and call Resume for each.
func (*Client) RegisterEngine ¶
RegisterEngine registers an engine under a logical name.
func (*Client) Resume ¶ added in v0.11.0
Resume polls a previously submitted async task to completion. The taskID is the aigo-side ID returned by Submit.
func (*Client) Submit ¶ added in v0.11.0
func (c *Client) Submit(ctx context.Context, engineName string, graph workflow.Graph, opts ...ExecuteOption) (string, error)
Submit executes the graph and persists the task for crash recovery. If the engine completes synchronously, the result is stored as completed and an empty task ID is returned. If the engine returns a remote task ID (WaitForCompletion=false), the record is stored as pending and the aigo-side task ID is returned for later Resume.
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 ClientOption ¶ added in v0.11.0
type ClientOption func(*Client)
ClientOption configures the Client at construction time.
func WithDefaultStore ¶ added in v0.11.0
func WithDefaultStore() (ClientOption, error)
WithDefaultStore attaches a FileTaskStore at .aigo/tasks.json (current working directory). Returns an error if the store directory cannot be created.
func WithStore ¶ added in v0.11.0
func WithStore(s TaskStore) ClientOption
WithStore attaches a TaskStore for async task persistence and crash recovery.
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 FileTaskStore ¶ added in v0.11.0
type FileTaskStore struct {
// contains filtered or unexported fields
}
FileTaskStore implements TaskStore using a single JSON file. It uses sync.Mutex for in-process safety and flock for cross-process safety.
func DefaultFileTaskStore ¶ added in v0.11.0
func DefaultFileTaskStore() (*FileTaskStore, error)
DefaultFileTaskStore creates a file-backed task store at .aigo/tasks.json relative to the current working directory.
func NewFileTaskStore ¶ added in v0.11.0
func NewFileTaskStore(path string) (*FileTaskStore, error)
NewFileTaskStore creates a file-backed task store at the given path.
func (*FileTaskStore) All ¶ added in v0.11.0
func (s *FileTaskStore) All() ([]TaskRecord, error)
func (*FileTaskStore) Delete ¶ added in v0.11.0
func (s *FileTaskStore) Delete(id string) error
func (*FileTaskStore) Load ¶ added in v0.11.0
func (s *FileTaskStore) Load(id string) (TaskRecord, error)
func (*FileTaskStore) Purge ¶ added in v0.11.0
func (s *FileTaskStore) Purge(maxAge time.Duration) error
Purge removes completed and failed records older than maxAge.
func (*FileTaskStore) Save ¶ added in v0.11.0
func (s *FileTaskStore) Save(record TaskRecord) error
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 MusicOptions ¶ added in v0.10.0
type MusicOptions struct {
Lyrics string
IsInstrumental *bool
LyricsOptimizer *bool
OutputFormat string // "url" or "hex"
SampleRate int
Bitrate int
Format string // "mp3", "wav", "flac"
}
MusicOptions groups music generation parameters.
type OutputKind ¶
type OutputKind = engine.OutputKind
OutputKind is an alias for engine.OutputKind.
func InterpretOutputKind ¶
func InterpretOutputKind(s string) OutputKind
InterpretOutputKind 根据内容前缀做轻量分类;任务 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.
type TTSOptions ¶
type TTSOptions struct {
Voice string
LanguageType string
Instructions string
OptimizeInstructions *bool
}
TTSOptions groups text-to-speech parameters.
type TaskRecord ¶ added in v0.11.0
type TaskRecord struct {
ID string `json:"id"`
EngineName string `json:"engine"`
RemoteID string `json:"remote_id"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ResultVal string `json:"result_value,omitempty"`
ResultKind OutputKind `json:"result_kind,omitempty"`
ErrMsg string `json:"error,omitempty"`
}
TaskRecord represents a persisted async task.
type TaskStore ¶ added in v0.11.0
type TaskStore interface {
Save(record TaskRecord) error
Load(id string) (TaskRecord, error)
All() ([]TaskRecord, error)
Delete(id string) error
}
TaskStore persists async task records for crash recovery.
Source Files
¶
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. |
|
comfydeploy
Package comfydeploy implements engine.Engine for the ComfyDeploy API.
|
Package comfydeploy implements engine.Engine for the ComfyDeploy API. |
|
elevenlabs
Package elevenlabs implements engine.Engine for the ElevenLabs TTS API.
|
Package elevenlabs implements engine.Engine for the ElevenLabs TTS API. |
|
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. |
|
fal
Package fal implements engine.Engine for the Fal.ai inference platform.
|
Package fal implements engine.Engine for the Fal.ai inference platform. |
|
flux
Package flux implements engine.Engine for Black Forest Labs FLUX API.
|
Package flux implements engine.Engine for Black Forest Labs FLUX API. |
|
gemini
Package gemini implements engine.Engine for Google Gemini multi-modal understanding.
|
Package gemini implements engine.Engine for Google Gemini multi-modal understanding. |
|
google
Package google implements engine.Engine for Google Imagen and Veo APIs.
|
Package google implements engine.Engine for Google Imagen and Veo APIs. |
|
gpt4o
Package gpt4o implements engine.Engine for OpenAI GPT-4o vision understanding.
|
Package gpt4o implements engine.Engine for OpenAI GPT-4o vision understanding. |
|
hailuo
Package hailuo implements engine.Engine for Hailuo (MiniMax) video generation.
|
Package hailuo implements engine.Engine for Hailuo (MiniMax) video generation. |
|
hedra
Package hedra implements engine.Engine for the Hedra character video API.
|
Package hedra implements engine.Engine for the Hedra character video API. |
|
httpx
Package httpx 提供各引擎共用的 HTTP Client 默认值(超时等)。
|
Package httpx 提供各引擎共用的 HTTP Client 默认值(超时等)。 |
|
ideogram
Package ideogram implements engine.Engine for the Ideogram API.
|
Package ideogram implements engine.Engine for the Ideogram API. |
|
jimeng
Package jimeng implements engine.Engine for the Jimeng (即梦) API by ByteDance.
|
Package jimeng implements engine.Engine for the Jimeng (即梦) API by ByteDance. |
|
kling
Package kling implements engine.Engine for the Kling (快手可灵) API.
|
Package kling implements engine.Engine for the Kling (快手可灵) API. |
|
liblib
Package liblib implements engine.Engine for the LibLibAI open API.
|
Package liblib implements engine.Engine for the LibLibAI open API. |
|
luma
Package luma implements engine.Engine for the Luma Dream Machine API.
|
Package luma implements engine.Engine for the Luma Dream Machine API. |
|
meshy
Package meshy implements engine.Engine for the Meshy 3D model generation API.
|
Package meshy implements engine.Engine for the Meshy 3D model generation API. |
|
midjourney
Package midjourney implements engine.Engine for MidJourney image generation via third-party proxy APIs (e.g.
|
Package midjourney implements engine.Engine for MidJourney image generation via third-party proxy APIs (e.g. |
|
minimax
Package minimax implements engine.Engine for MiniMax music generation.
|
Package minimax implements engine.Engine for MiniMax music generation. |
|
newapi
Package newapi 对接 New API 文档中的大模型 HTTP 接口(图像 / 视频 / 语音等)。
|
Package newapi 对接 New API 文档中的大模型 HTTP 接口(图像 / 视频 / 语音等)。 |
|
newapi/internal/rt
Package rt 提供网关 BaseURL 规范化与路径拼接。
|
Package rt 提供网关 BaseURL 规范化与路径拼接。 |
|
openrouter
Package openrouter implements an aigo engine for the OpenRouter API.
|
Package openrouter implements an aigo engine for the OpenRouter API. |
|
pika
Package pika implements engine.Engine for the Pika video generation API.
|
Package pika implements engine.Engine for the Pika video generation API. |
|
recraft
Package recraft implements engine.Engine for the Recraft AI API.
|
Package recraft implements engine.Engine for the Recraft AI API. |
|
replicate
Package replicate implements engine.Engine for the Replicate API.
|
Package replicate implements engine.Engine for the Replicate API. |
|
runninghub
Package runninghub implements engine.Engine for the RunningHub API.
|
Package runninghub implements engine.Engine for the RunningHub API. |
|
runway
Package runway implements engine.Engine for the Runway API.
|
Package runway implements engine.Engine for the Runway API. |
|
stability
Package stability implements engine.Engine for the Stability AI API.
|
Package stability implements engine.Engine for the Stability AI API. |
|
suno
Package suno implements engine.Engine for Suno music generation.
|
Package suno implements engine.Engine for Suno music generation. |
|
volcvoice
Package volcvoice implements engine.Engine for Volcengine Speech (火山语音 / openspeech.bytedance.com) TTS and ASR.
|
Package volcvoice implements engine.Engine for Volcengine Speech (火山语音 / openspeech.bytedance.com) TTS and ASR. |
|
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. |