MCPcopy Create free account
hub / github.com/aurora-develop/aurora / buildToolCallFromRaw

Function buildToolCallFromRaw

internal/toolcall/parser.go:166–183  ·  view source on GitHub ↗

buildToolCallFromRaw 尝试把 内的纯文本解析成 ToolCall。 失败时返回 nil(让上层决定是否作为文本回吐)。

(raw string)

Source from the content-addressed store, hash-verified

164// buildToolCallFromRaw 尝试把 <tool_call> 内的纯文本解析成 ToolCall。
165// 失败时返回 nil(让上层决定是否作为文本回吐)。
166func buildToolCallFromRaw(raw string) *official.ToolCall {
167 s := strings.TrimSpace(raw)
168 if s == "" {
169 return nil
170 }
171 // 去掉 markdown 围栏
172 s = stripMarkdownFence(s)
173 idx := strings.Index(s, "{")
174 if idx < 0 {
175 return nil
176 }
177 s = s[idx:]
178 obj, ok := robustJSON(s)
179 if !ok {
180 return nil
181 }
182 return buildToolCallFromObject(obj)
183}
184
185func stripMarkdownFence(s string) string {
186 s = fenceOpenRe.ReplaceAllString(s, "")

Callers 2

FeedMethod · 0.85
FlushMethod · 0.85

Calls 3

stripMarkdownFenceFunction · 0.85
robustJSONFunction · 0.85
buildToolCallFromObjectFunction · 0.85

Tested by

no test coverage detected