MCPcopy Create free account
hub / github.com/astercloud/aster / parseStepResponse

Method parseStepResponse

pkg/reasoning/engine.go:179–200  ·  view source on GitHub ↗

parseStepResponse 解析步骤响应

(response *provider.CompleteResponse)

Source from the content-addressed store, hash-verified

177
178// parseStepResponse 解析步骤响应
179func (e *Engine) parseStepResponse(response *provider.CompleteResponse) (*Step, error) {
180 // 提取文本内容
181 text := ""
182 var textSb182 strings.Builder
183 for _, block := range response.Message.ContentBlocks {
184 if textBlock, ok := block.(*types.TextBlock); ok {
185 textSb182.WriteString(textBlock.Text)
186 }
187 }
188 text += textSb182.String()
189
190 // 尝试 JSON 解析
191 if e.config.UseJSON {
192 step, err := e.parseJSONStep(text)
193 if err == nil {
194 return step, nil
195 }
196 }
197
198 // 回退到文本解析
199 return e.parseTextStep(text)
200}
201
202// parseJSONStep 解析 JSON 格式的步骤
203func (e *Engine) parseJSONStep(text string) (*Step, error) {

Callers 1

executeReasoningStepMethod · 0.95

Calls 3

parseJSONStepMethod · 0.95
parseTextStepMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected