Documentation
¶
Index ¶
Constants ¶
View Source
const ThinkingSep = "\x02"
ThinkingSep 是思考文本与正文之间的分隔标记。 StreamFilter 在思考文本段前插入此标记,TUI 据此切换渲染样式。
Variables ¶
This section is empty.
Functions ¶
func CleanInputRunes ¶
func CleanInputText ¶
CleanInputText 删除终端输入中没有业务意义的控制字符,保留用户可见文本。 单行输入场景下,粘贴文本里的换行和制表符会被归一为空格。
func ContainsControl ¶
Types ¶
type JSONFieldExtractor ¶
type JSONFieldExtractor struct {
// contains filtered or unexported fields
}
JSONFieldExtractor 从流式 JSON 碎片中提取指定字段的字符串值。
LLM 流式生成 tool call 时,参数是逐片段到达的(OpenAI/Anthropic) 或一次性到达的(Gemini)。本提取器用状态机逐字符扫描, 检测到目标 key 后提取其字符串值,处理 JSON 转义。
func NewFieldExtractor ¶
func NewFieldExtractor(fieldName string) *JSONFieldExtractor
func (*JSONFieldExtractor) Feed ¶
func (e *JSONFieldExtractor) Feed(delta string) string
Feed 处理一段 delta,返回提取到的文本(可能为空)。
type StreamFilter ¶
type StreamFilter struct {
// contains filtered or unexported fields
}
StreamFilter 区分 SubAgent 的文本回复和 JSON 工具调用。 文本回复标记为思考内容(前缀 ThinkingSep);JSON 工具调用只提取指定字段。
判断依据:遇到 { 进入 JSON 模式(追踪大括号深度), 深度归零后回到文本模式。
func NewStreamFilter ¶
func NewStreamFilter(fieldName string) *StreamFilter
func (*StreamFilter) Feed ¶
func (f *StreamFilter) Feed(delta string) string
Feed 处理一段 delta,返回可展示文本。 文本回复直接输出;JSON 中的目标字段值被提取输出;其余 JSON 结构丢弃。
Click to show internal directories.
Click to hide internal directories.