python

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option configures a Python runner.

func WithDependencies

func WithDependencies(pkgs ...string) Option

WithDependencies declares Python packages available to the executed code.

func WithRuntimeOptions

func WithRuntimeOptions(opts ...pyffi.Option) Option

WithRuntimeOptions passes additional pyffi.Option values.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the default execution timeout per Run call.

type Runner

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

Runner is a Python code execution runner backed by pyffi (CPython). It implements codeact.Runner and additionally exposes RegisterFunc for injecting Go functions callable from Python via go_bridge.

func NewRunner

func NewRunner(opts ...Option) (*Runner, error)

NewRunner creates a Python code execution runner.

func (*Runner) Close

func (r *Runner) Close() error

func (*Runner) Language

func (r *Runner) Language() string

func (*Runner) RegisterAnyFunc

func (r *Runner) RegisterAnyFunc(name string, fn any) error

RegisterAnyFunc registers an arbitrary Go function callable from Python. For Python this is identical to RegisterFunc since pyffi already accepts any.

func (*Runner) RegisterFunc

func (r *Runner) RegisterFunc(name string, fn any) error

RegisterFunc registers a Go function callable from Python via go_bridge.

runner.RegisterFunc("queryDB", func(sql string) ([]map[string]any, error) {
    return db.Query(ctx, sql)
})

In Python: import go_bridge; rows = go_bridge.queryDB("SELECT * FROM users")

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, code string) (*codeact.RunResult, error)

func (*Runner) ToolDescription

func (r *Runner) ToolDescription() string

func (*Runner) ToolName

func (r *Runner) ToolName() string

Jump to

Keyboard shortcuts

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