Documentation
¶
Index ¶
- type Option
- type Runner
- func (r *Runner) Close() error
- func (r *Runner) Language() string
- func (r *Runner) RegisterAnyFunc(name string, fn any) error
- func (r *Runner) RegisterFunc(name string, fn any) error
- func (r *Runner) Run(ctx context.Context, code string) (*codeact.RunResult, error)
- func (r *Runner) ToolDescription() string
- func (r *Runner) ToolName() string
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 ¶
WithDependencies declares Python packages available to the executed code.
func WithRuntimeOptions ¶
WithRuntimeOptions passes additional pyffi.Option values.
func WithTimeout ¶
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 (*Runner) RegisterAnyFunc ¶
RegisterAnyFunc registers an arbitrary Go function callable from Python. For Python this is identical to RegisterFunc since pyffi already accepts any.
func (*Runner) RegisterFunc ¶
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")