warp

package
v1.3.5 Latest Latest
Warning

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

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

Documentation

Overview

Package warp 定义节点装饰器:与 hook(横向切面,管节点前后)平级,

warp 是纵向封装,管节点内部。模型用 ModelHandler / Model,工具用 ToolHandler / Tool,链式组装共用 Chain。

装饰器在每次 Run 组装时由引擎注入 per-Run 的 event.Emitter:节点内部的 事件(重试、降级)经它显式发出;warp 实例 per-Run 化,状态不跨 Run 共享。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain[T any](em event.Emitter, node T, handlers ...Handler[T]) T

Chain 用装饰器链包装 node:先注册的位于最外层,即调用依次经过

h1 → h2 → ... → node。每次 Run 调用。

func Model

Model 用装饰器链包装模型节点:先注册的位于最外层。

func Tool

func Tool(em event.Emitter, t types.Tool, handlers ...ToolHandler) types.Tool

Tool 用装饰器链包装工具节点:先注册的位于最外层。

Types

type Handler

type Handler[T any] func(em event.Emitter, node T) T

Handler 是节点装饰器:组装时注入 per-Run 事件出口,返回增强后的节点。

类比 net/http 的 middleware 惯用法。

type ModelHandler

type ModelHandler = Handler[provider.ModelProvider]

ModelHandler 是模型节点装饰器:重试、降级、限流、多模型路由等。

type ToolHandler

type ToolHandler = Handler[types.Tool]

ToolHandler 是工具节点装饰器:防护、超时、审计、缓存等。

Jump to

Keyboard shortcuts

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