mediagen

package
v1.5.4 Latest Latest
Warning

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

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

Documentation

Overview

Package mediagen provides the built-in image__generate and video__generate tools. They let a text agent generate media as one step of a conversation by resolving an image/video provider from the shared provider pool (base.Registry) and invoking its Generate method.

The package lives in runtime so both the SDK and Arena can wire it without duplicating provider-resolution logic. It depends only on runtime/providers/base, runtime/tools, and runtime/types — never on sdk or tools/arena.

Index

Constants

View Source
const (
	// ImageGenerateToolName is the qualified name of the image generation tool.
	ImageGenerateToolName = "image__generate"
	// VideoGenerateToolName is the qualified name of the video generation tool.
	VideoGenerateToolName = "video__generate"
	// ExecutorMode is the tool Mode that routes to the mediagen Executor.
	ExecutorMode = "mediagen"
)

Variables

This section is empty.

Functions

func ImageGenerateDescriptor

func ImageGenerateDescriptor() *tools.ToolDescriptor

ImageGenerateDescriptor returns the descriptor for the image__generate tool.

func VideoGenerateDescriptor

func VideoGenerateDescriptor() *tools.ToolDescriptor

VideoGenerateDescriptor returns the descriptor for the video__generate tool.

Types

type Executor

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

Executor resolves an image/video provider from the pool and invokes its Generate method, returning the result as a media ContentPart that flows into the conversation message log. It implements tools.MultimodalExecutor.

func NewExecutor

func NewExecutor(pool *base.Registry) *Executor

NewExecutor returns an Executor backed by the given provider pool. The pool may be nil; in that case every call resolves to a "no provider configured" error returned to the calling agent.

func (*Executor) Execute

func (e *Executor) Execute(
	ctx context.Context, descriptor *tools.ToolDescriptor, args json.RawMessage,
) (json.RawMessage, error)

Execute satisfies tools.Executor. mediagen always produces media parts, so this returns the JSON summary and drops the parts; the registry prefers ExecuteMultimodal where available.

func (*Executor) ExecuteMultimodal

func (e *Executor) ExecuteMultimodal(
	ctx context.Context, descriptor *tools.ToolDescriptor, args json.RawMessage,
) (json.RawMessage, []types.ContentPart, error)

ExecuteMultimodal generates media and returns a JSON summary plus the media ContentParts. An unresolved provider, a provider error, or empty output is returned as an error so the agent sees a clear tool failure rather than a silent no-op.

func (*Executor) Name

func (e *Executor) Name() string

Name returns the executor mode string. It must match ToolDescriptor.Mode.

Jump to

Keyboard shortcuts

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