Unverified Commit aea6fb9b authored by Parth Sareen's avatar Parth Sareen Committed by GitHub
Browse files

tools: remove newline stripping (#10869)

parent 012cf653
......@@ -137,11 +137,6 @@ func parseJSONToolCalls(s string, name, arguments string, prefix string) ([]api.
// - The processed string with prefix removed if found
// - error: ErrAccumulateMore if prefix is incomplete, or nil if successful
func (p *Parser) checkPrefix(s string) (string, error) {
original := s
if strings.ContainsRune(s, '\n') {
s = strings.ReplaceAll(s, "\n", " ")
}
if s == "" || p.prefix == "" {
return s, nil
}
......@@ -158,7 +153,7 @@ func (p *Parser) checkPrefix(s string) (string, error) {
// Return everything except overlapping portion
p.sb.Reset()
p.sb.WriteString(s[idx:])
return original[:idx], errAccumulateMore
return s[:idx], errAccumulateMore
}
// Check if prefix appears in middle of string
......@@ -167,7 +162,7 @@ func (p *Parser) checkPrefix(s string) (string, error) {
p.sb.Reset()
p.sb.WriteString(strings.TrimSpace(s[idx:]))
// Return everything before prefix
return original[:idx], errAccumulateMore
return s[:idx], errAccumulateMore
}
// No partial prefix found
......@@ -181,9 +176,6 @@ func (p *Parser) checkPrefix(s string) (string, error) {
// - tools: Any parsed tool calls
// - content: Non-tool call content
func (p *Parser) Add(s string) (tools []api.ToolCall, content string) {
if strings.TrimSpace(s) == "" {
return nil, s
}
if p.done {
if p.index == 0 {
// Return original string if no tool calls found at start
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment