Help us shape the future of Go! Take the 2026 Go Developer Survey

reflection

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package reflection 反思(Reflection)架构原语:生成 → 自我批判 → 修订的收敛循环。

流程:按 Task 对 Input 产出初稿 → Critic 按 Rubric 评审(结构化 JSON: pass/issues)→ 未通过则带 issues 修订重写 → 收敛(pass)或达轮次上限返回末稿。

适用:对产出质量有硬标准、且标准可被模型自评的任务(代码实现、报告撰写、 翻译润色);标准主观或需要外部事实核验的场景,Critic 不可靠,不适用。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Model 生成/评审共用的模型(内部包 llm.Client:带重试与 JSON 解析回喂)。
	Model model.BaseChatModel
	// ModelName 模型名(记账/日志标识)。
	ModelName string
	// Task 任务指令:要生成什么(如"实现该需求的 Go 函数")。
	Task string
	// Input 待处理的素材(需求文本/diff/问题;可空)。
	Input string
	// Rubric 评审标准:Critic 据此判定 pass/issues(尽可能可判定、可执行)。
	Rubric string
	// MaxIterations 最大"批判→修订"轮数(默认 3;1 = 只批判一次不修订也要跑)。
	MaxIterations int
}

Config 反思循环配置。

type Result

type Result struct {
	// Text 末稿(收敛稿或达上限时的最佳稿)——与 acpx.RunResult.Text、
	// agentrun.Event.Text 同词表(Text=模型/agent 最终产出文本)。
	Text string
	// Rounds 每轮记录(Round[0] = 初稿)。
	Rounds []Round
	// Converged 是否通过 Rubric 收敛(false = 达到轮次上限返回末稿)。
	// Stalled 稿差判停提前终止(修订稿与上一稿几乎相同——同稿重发形态,
	// 再烧轮次无意义;Text 为该重复稿)。
	Stalled   bool
	Converged bool
}

Result 反思循环结果。

func Refine

func Refine(ctx context.Context, cfg *Config) (*Result, error)

Refine 运行反思循环。

type Round

type Round struct {
	Draft    string
	Pass     bool
	Issues   []string
	Critique string // Critic 原始 JSON(审计留痕)
}

Round 一轮(初稿或修订稿 + 该稿的批判结论)。

Jump to

Keyboard shortcuts

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