local

package
v0.0.0-...-1c978d5 Latest Latest
Warning

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

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

Documentation

Overview

Package local 把本地 Go 函数包装成能力,零配置成本。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Func

func Func[T, D any](name, description string, fn func(ctx context.Context, in T) (D, error)) (capability.Capability, error)

Func 用泛型推断参数 schema,把一个 Go 函数变成能力(默认只读)。 T 的字段通过 json/jsonschema tag 描述,和 eino utils.InferTool 一致:

type WeatherReq struct {
    City string `json:"city" jsonschema:"description=城市名"`
}
cap, _ := local.Func("get_weather", "查询城市天气", fn)

func FuncWithRisk

func FuncWithRisk[T, D any](name, description string, risk capability.Risk, fn func(ctx context.Context, in T) (D, error)) (capability.Capability, error)

FuncWithRisk 同 Func,但显式声明风险级别(写操作应标记 mutating)。

Types

This section is empty.

Jump to

Keyboard shortcuts

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