engine

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveKey added in v0.13.0

func ResolveKey(explicit string, envVars ...string) (string, error)

ResolveKey resolves an API key by checking the explicit value first, then falling back to the given environment variable names in order. Returns an error listing all checked sources if no key is found.

func ResolveKeyPair added in v0.13.0

func ResolveKeyPair(ak, sk string, akEnvs, skEnvs []string) (string, string, error)

ResolveKeyPair resolves a pair of keys (e.g. AccessKey + SecretKey). Each key is resolved independently via ResolveKey.

Types

type Cache added in v0.13.0

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

Cache wraps an Engine and caches successful results keyed by graph content.

func WithCache added in v0.13.0

func WithCache(e Engine, ttl time.Duration, maxSize int) *Cache

WithCache wraps an Engine with a result cache. ttl controls how long results are cached; maxSize limits the number of entries.

func (*Cache) Clear added in v0.13.0

func (c *Cache) Clear()

Clear removes all cached entries.

func (*Cache) Execute added in v0.13.0

func (c *Cache) Execute(ctx context.Context, g workflow.Graph) (Result, error)

Execute checks the cache before delegating to the underlying engine.

func (*Cache) Len added in v0.13.0

func (c *Cache) Len() int

Len returns the number of entries currently in the cache.

type Capability

type Capability struct {
	MediaTypes   []string // e.g. ["image", "video", "audio"]
	Models       []string
	Sizes        []string // e.g. ["1024x1024", "1280x720"]
	Voices       []string // supported voice identifiers for TTS engines
	MaxDuration  int      // max video/audio duration in seconds; 0 = not applicable
	SupportsSync bool
	SupportsPoll bool
}

Capability describes what an engine can do.

type ConfigField added in v0.9.0

type ConfigField struct {
	Key         string `json:"key"`   // field identifier, e.g. "apiKey", "appId"
	Label       string `json:"label"` // human-readable label, e.g. "API Key"
	Type        string `json:"type"`  // "string", "secret", "url"
	Required    bool   `json:"required"`
	EnvVar      string `json:"envVar,omitempty"` // fallback environment variable name
	Description string `json:"description,omitempty"`
	Default     string `json:"default,omitempty"`
}

ConfigField describes a single configuration parameter for an engine provider. Engine packages expose a package-level ConfigSchema() []ConfigField function so that UIs can dynamically render configuration forms.

type Describer

type Describer interface {
	Capabilities() Capability
}

Describer is an optional interface that engines can implement to advertise capabilities.

type Discoverer added in v0.7.0

type Discoverer interface {
	ModelsByCapability() map[string][]string
}

Discoverer is a package-level interface for providers that can enumerate all known models grouped by capability (e.g. "image", "video", "tts"). Unlike Engine (per-instance), Discoverer is a static catalog of models the provider SDK knows how to handle.

type DryRunResult

type DryRunResult struct {
	WillPoll      bool
	EstimatedTime string   // human-readable estimate, e.g. "30s-2m"
	Warnings      []string // potential issues with the request
}

DryRunResult is the outcome of a dry-run estimation.

type DryRunner

type DryRunner interface {
	DryRun(graph workflow.Graph) (DryRunResult, error)
}

DryRunner is an optional interface for engines that support dry-run estimation.

type Engine

type Engine interface {
	Execute(ctx context.Context, graph workflow.Graph) (Result, error)
}

Engine executes a workflow graph against a concrete backend.

type Entry added in v0.13.0

type Entry struct {
	Name               string
	Engine             Engine
	ConfigSchemaFunc   func() []ConfigField
	ModelsByCapability func() map[string][]string
}

Entry describes a registered engine provider.

type OutputKind

type OutputKind int

OutputKind classifies the string returned by an engine.

const (
	OutputUnknown OutputKind = iota
	OutputURL
	OutputDataURI
	OutputJSON
	OutputPlainText
)

func ClassifyOutput added in v0.8.0

func ClassifyOutput(s string) OutputKind

ClassifyOutput heuristically classifies a raw output string.

type Registry added in v0.13.0

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

Registry provides engine registration, lookup, and discovery.

func NewRegistry added in v0.13.0

func NewRegistry() *Registry

NewRegistry creates an empty engine registry.

func (*Registry) AllConfigSchemas added in v0.13.0

func (r *Registry) AllConfigSchemas() map[string][]ConfigField

AllConfigSchemas returns the configuration schema for each registered engine.

func (*Registry) AllModels added in v0.13.0

func (r *Registry) AllModels() map[string]map[string][]string

AllModels returns all registered models grouped by engine name and capability. Result: map[engineName]map[capability][]models

func (*Registry) FindByCapability added in v0.13.0

func (r *Registry) FindByCapability(mediaType string) []Entry

FindByCapability returns all entries whose ModelsByCapability includes the given media type.

func (*Registry) Get added in v0.13.0

func (r *Registry) Get(name string) (Entry, bool)

Get returns the entry for the given engine name.

func (*Registry) Len added in v0.13.0

func (r *Registry) Len() int

Len returns the number of registered engines.

func (*Registry) List added in v0.13.0

func (r *Registry) List() []string

List returns all registered engine names in sorted order.

func (*Registry) Register added in v0.13.0

func (r *Registry) Register(name string, e Entry)

Register adds an engine entry to the registry. If an entry with the same name exists, it is replaced.

type Result

type Result struct {
	Value   string
	Kind    OutputKind
	Results []ResultItem // multiple results for batch generation; may be nil for single-result engines
}

Result is the structured output of Engine.Execute.

type ResultItem added in v0.13.0

type ResultItem struct {
	Value    string            // output URL, data URI, or text
	Kind     OutputKind        // classification of Value
	Metadata map[string]string // engine-specific metadata (e.g. "seed", "index")
}

ResultItem represents a single output in a multi-result response.

type Resumer added in v0.11.0

type Resumer interface {
	Resume(ctx context.Context, remoteID string) (Result, error)
}

Resumer is an optional interface for engines that support resuming an already-submitted async task by its remote ID.

type WebhookConfig added in v0.13.0

type WebhookConfig struct {
	URL     string            // webhook endpoint
	Secret  string            // optional signing secret for verification
	Headers map[string]string // optional additional headers
}

WebhookConfig is a common webhook configuration for engines that support completion notifications via webhook.

Directories

Path Synopsis
Package aigoerr provides structured, classifiable errors for aigo engines.
Package aigoerr provides structured, classifiable errors for aigo engines.
Package aliyun 对接阿里云百炼(DashScope)多模态 API。
Package aliyun 对接阿里云百炼(DashScope)多模态 API。
internal/async
Package async 封装百炼异步任务创建与轮询(图生图、文生视频等共用)。
Package async 封装百炼异步任务创建与轮询(图生图、文生视频等共用)。
internal/audiogen
Package audiogen 实现阿里云百炼「语音合成 / 声音设计」类能力。
Package audiogen 实现阿里云百炼「语音合成 / 声音设计」类能力。
internal/graphx
Package graphx 从 workflow.Graph 抽取各域(图/视频/音频)共用字段。
Package graphx 从 workflow.Graph 抽取各域(图/视频/音频)共用字段。
internal/imggen
Package imggen 实现阿里云百炼「图片生成」类能力(文生图等)。
Package imggen 实现阿里云百炼「图片生成」类能力(文生图等)。
internal/vidgen
Package vidgen 实现阿里云百炼「视频生成 / 编辑」类能力(Wan 系列异步接口)。
Package vidgen 实现阿里云百炼「视频生成 / 编辑」类能力(Wan 系列异步接口)。
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.
Package comfydeploy implements engine.Engine for the ComfyDeploy API.
Package comfydeploy implements engine.Engine for the ComfyDeploy API.
Package elevenlabs implements engine.Engine for the ElevenLabs TTS API.
Package elevenlabs implements engine.Engine for the ElevenLabs TTS API.
Package embed defines the EmbedEngine interface for vector embedding backends.
Package embed defines the EmbedEngine interface for vector embedding backends.
aliyun
Package aliyun implements the Alibaba Cloud DashScope (Bailian) embedding backend.
Package aliyun implements the Alibaba Cloud DashScope (Bailian) embedding backend.
gemini
Package gemini implements the Gemini Embedding 2 backend.
Package gemini implements the Gemini Embedding 2 backend.
jina
Package jina implements the Jina AI embedding backend.
Package jina implements the Jina AI embedding backend.
openai
Package openai implements the OpenAI text embedding backend.
Package openai implements the OpenAI text embedding backend.
voyage
Package voyage implements the Voyage AI embedding backend.
Package voyage implements the Voyage AI embedding backend.
Package fal implements engine.Engine for the Fal.ai inference platform.
Package fal implements engine.Engine for the Fal.ai inference platform.
Package flux implements engine.Engine for Black Forest Labs FLUX API.
Package flux implements engine.Engine for Black Forest Labs FLUX API.
Package gemini implements engine.Engine for Google Gemini multi-modal understanding.
Package gemini implements engine.Engine for Google Gemini multi-modal understanding.
Package google implements engine.Engine for Google Imagen and Veo APIs.
Package google implements engine.Engine for Google Imagen and Veo APIs.
Package gpt4o implements engine.Engine for OpenAI GPT-4o vision understanding.
Package gpt4o implements engine.Engine for OpenAI GPT-4o vision understanding.
Package hailuo implements engine.Engine for Hailuo (MiniMax) video generation.
Package hailuo implements engine.Engine for Hailuo (MiniMax) video generation.
Package hedra implements engine.Engine for the Hedra character video API.
Package hedra implements engine.Engine for the Hedra character video API.
Package httpx 提供各引擎共用的 HTTP Client 默认值(超时等)。
Package httpx 提供各引擎共用的 HTTP Client 默认值(超时等)。
Package ideogram implements engine.Engine for the Ideogram API.
Package ideogram implements engine.Engine for the Ideogram API.
Package jimeng implements engine.Engine for the Jimeng (即梦) API by ByteDance.
Package jimeng implements engine.Engine for the Jimeng (即梦) API by ByteDance.
Package kling implements engine.Engine for the Kling (快手可灵) API.
Package kling implements engine.Engine for the Kling (快手可灵) API.
Package liblib implements engine.Engine for the LibLibAI open API.
Package liblib implements engine.Engine for the LibLibAI open API.
Package luma implements engine.Engine for the Luma Dream Machine API.
Package luma implements engine.Engine for the Luma Dream Machine API.
Package meshy implements engine.Engine for the Meshy 3D model generation API.
Package meshy implements engine.Engine for the Meshy 3D model generation API.
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.
Package minimax implements engine.Engine for MiniMax music generation.
Package minimax implements engine.Engine for MiniMax music generation.
Package newapi 对接 New API 文档中的大模型 HTTP 接口(图像 / 视频 / 语音等)。
Package newapi 对接 New API 文档中的大模型 HTTP 接口(图像 / 视频 / 语音等)。
internal/rt
Package rt 提供网关 BaseURL 规范化与路径拼接。
Package rt 提供网关 BaseURL 规范化与路径拼接。
Package openrouter implements an aigo engine for the OpenRouter API.
Package openrouter implements an aigo engine for the OpenRouter API.
Package pika implements engine.Engine for the Pika video generation API.
Package pika implements engine.Engine for the Pika video generation API.
Package recraft implements engine.Engine for the Recraft AI API.
Package recraft implements engine.Engine for the Recraft AI API.
Package replicate implements engine.Engine for the Replicate API.
Package replicate implements engine.Engine for the Replicate API.
Package runninghub implements engine.Engine for the RunningHub API.
Package runninghub implements engine.Engine for the RunningHub API.
Package runway implements engine.Engine for the Runway API.
Package runway implements engine.Engine for the Runway API.
Package stability implements engine.Engine for the Stability AI API.
Package stability implements engine.Engine for the Stability AI API.
Package suno implements engine.Engine for Suno music generation.
Package suno implements engine.Engine for Suno music generation.
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.

Jump to

Keyboard shortcuts

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