Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
aea6fb9b
Unverified
Commit
aea6fb9b
authored
May 26, 2025
by
Parth Sareen
Committed by
GitHub
May 26, 2025
Browse files
tools: remove newline stripping (#10869)
parent
012cf653
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
10 deletions
+2
-10
tools/tools.go
tools/tools.go
+2
-10
No files found.
tools/tools.go
View file @
aea6fb9b
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment