normalize 把模型常见的标签变体( 、 等)统一为 / 。
(s string)
| 139 | // normalize 把模型常见的标签变体(<tool_calls>、<tool call> 等)统一为 |
| 140 | // <tool_call> / </tool_call>。 |
| 141 | func normalize(s string) string { |
| 142 | s = toolCallsOpenRe.ReplaceAllString(s, StartTag) |
| 143 | s = toolCallsCloseRe.ReplaceAllString(s, EndTag) |
| 144 | s = toolCallAltOpenRe.ReplaceAllString(s, StartTag) |
| 145 | s = toolCallAltCloseRe.ReplaceAllString(s, EndTag) |
| 146 | return s |
| 147 | } |
| 148 | |
| 149 | var ( |
| 150 | toolCallsOpenRe = regexp.MustCompile(`(?i)<tool_calls>`) |