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
dbfd7bd0
Unverified
Commit
dbfd7bd0
authored
Aug 11, 2025
by
Devon Rifkin
Committed by
GitHub
Aug 11, 2025
Browse files
Merge pull request #11861 from ollama/drifkin/fix-parsing-error
server: fix error when parsing bad harmony tool calls
parents
ea7657b5
ee04dbba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
server/routes.go
server/routes.go
+4
-2
No files found.
server/routes.go
View file @
dbfd7bd0
...
@@ -371,7 +371,8 @@ func (s *Server) GenerateHandler(c *gin.Context) {
...
@@ -371,7 +371,8 @@ func (s *Server) GenerateHandler(c *gin.Context) {
*
toolName
=
strings
.
TrimPrefix
(
*
toolName
,
"functions."
)
*
toolName
=
strings
.
TrimPrefix
(
*
toolName
,
"functions."
)
var
args
api
.
ToolCallFunctionArguments
var
args
api
.
ToolCallFunctionArguments
if
err
:=
json
.
Unmarshal
([]
byte
(
toolContent
),
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
toolContent
),
&
args
);
err
!=
nil
{
ch
<-
gin
.
H
{
"error parsing tool call"
:
err
.
Error
()}
errStr
:=
fmt
.
Sprintf
(
"error parsing tool call: raw='%s', err=%s"
,
toolContent
,
err
.
Error
())
ch
<-
gin
.
H
{
"error"
:
errStr
}
return
return
}
}
...
@@ -1671,7 +1672,8 @@ func (s *Server) ChatHandler(c *gin.Context) {
...
@@ -1671,7 +1672,8 @@ func (s *Server) ChatHandler(c *gin.Context) {
*
toolName
=
strings
.
TrimPrefix
(
*
toolName
,
"functions."
)
*
toolName
=
strings
.
TrimPrefix
(
*
toolName
,
"functions."
)
var
args
api
.
ToolCallFunctionArguments
var
args
api
.
ToolCallFunctionArguments
if
err
:=
json
.
Unmarshal
([]
byte
(
toolContent
),
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
toolContent
),
&
args
);
err
!=
nil
{
ch
<-
gin
.
H
{
"error parsing tool call"
:
err
.
Error
()}
errStr
:=
fmt
.
Sprintf
(
"error parsing tool call: raw='%s', err=%s"
,
toolContent
,
err
.
Error
())
ch
<-
gin
.
H
{
"error"
:
errStr
}
return
return
}
}
res
.
Message
.
ToolCalls
=
[]
api
.
ToolCall
{{
Function
:
api
.
ToolCallFunction
{
Name
:
*
toolName
,
Arguments
:
args
}}}
res
.
Message
.
ToolCalls
=
[]
api
.
ToolCall
{{
Function
:
api
.
ToolCallFunction
{
Name
:
*
toolName
,
Arguments
:
args
}}}
...
...
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