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

Function marshalArguments

internal/toolcall/parser.go:338–360  ·  view source on GitHub ↗
(v any)

Source from the content-addressed store, hash-verified

336}
337
338func marshalArguments(v any) string {
339 switch t := v.(type) {
340 case nil:
341 return "{}"
342 case string:
343 s := strings.TrimSpace(t)
344 // 模型有时直接给对象,有时给字符串;统一为合法 JSON
345 if strings.HasPrefix(s, "{") {
346 if _, ok := robustJSON(s); ok {
347 return s
348 }
349 }
350 // 字符串不是 JSON,作为 command 类参数包一层
351 b, _ := json.Marshal(map[string]string{"command": s})
352 return string(b)
353 case map[string]any:
354 b, _ := json.Marshal(t)
355 return string(b)
356 default:
357 b, _ := json.Marshal(t)
358 return string(b)
359 }
360}
361
362// generateCallID 分配 call_xxx 风格的 ID,与 Python 保持一致
363// (24 个 hex 字符的随机后缀)。

Callers 1

buildToolCallFromObjectFunction · 0.85

Calls 1

robustJSONFunction · 0.85

Tested by

no test coverage detected