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
ee04dbba
Commit
ee04dbba
authored
Aug 11, 2025
by
Devon Rifkin
Browse files
server: fix error when parsing bad harmony tool calls
Thanks @moll for reporting! Fixes: #11781
parent
735c41f9
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 @
ee04dbba
...
@@ -364,7 +364,8 @@ func (s *Server) GenerateHandler(c *gin.Context) {
...
@@ -364,7 +364,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
}
}
...
@@ -1655,7 +1656,8 @@ func (s *Server) ChatHandler(c *gin.Context) {
...
@@ -1655,7 +1656,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