provider

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package provider 抽象模型调用节点,换模型/多模型路由均通过实现本接口扩展。

warp.go 定义模型中间件:引擎标准能力, 用户可提供 Warp 对模型调用做重试、降级、日志、限流、多模型路由等操作。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModelChunkHandler

type ModelChunkHandler func(chunk types.ModelChunk) error

ModelChunkHandler 接收流式增量;返回 error 可提前取消流。

type ModelProvider

type ModelProvider interface {
	Invoke(ctx context.Context, req *types.ModelRequest) (*types.ModelResponse, error)
}

ModelProvider 是非流式模型调用。

func Warp

func Warp(p ModelProvider, warps ...WarpHandler) ModelProvider

Warp 用中间件链包装 p:先注册的位于最外层, 即请求依次经过 warp1 → warp2 → ... → p。

type StreamProvider

type StreamProvider interface {
	Stream(ctx context.Context, req *types.ModelRequest, onChunk ModelChunkHandler) (*types.ModelResponse, error)
}

StreamProvider 是流式模型调用,聚合出完整响应后返回。

type WarpHandler

type WarpHandler func(ModelProvider) ModelProvider

WarpHandler 是模型中间件:接收一个 ModelProvider,返回增强后的实现。 类比 net/http 的 middleware 惯用法。

Jump to

Keyboard shortcuts

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