llmretry

package
v0.7.4 Latest Latest
Warning

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

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

Documentation

Overview

Package llmretry 是直接模型调用共用的请求层重试内核:仅重试模型适配器 明确标记为 retryable 的错误,遵守 Retry-After/指数退避,并经 ToolProgress 把进度送入既有工作台观察链。账户、鉴权、权限等终止错误会立即返回; retryable 错误持续重试,生命周期只由 context 控制。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, model Generator, cfg Config, messages []agentcore.Message, opts ...agentcore.CallOption) (*agentcore.LLMResponse, error)

Generate 调用 model.Generate。retryable 错误退避后持续重试,直到成功或 context 结束;非 retryable 错误立即返回。

Types

type Config

type Config struct {
	Agent   string
	OnRetry func(Event)
}

Config 配置重试的可观测信息,不改变重试语义。

type Event

type Event struct {
	Attempt int
	Delay   time.Duration
	Err     error
}

Event 描述一次即将发生的请求重试。

type Generator

type Generator interface {
	Generate(context.Context, []agentcore.Message, []agentcore.ToolSpec, ...agentcore.CallOption) (*agentcore.LLMResponse, error)
}

Generator 是请求重试所需的最小模型接口。

Jump to

Keyboard shortcuts

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