"src/graph/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "9a00cf194fcf994b2527cd927d691144f5e9c47b"
Unverified Commit dbfd7bd0 authored by Devon Rifkin's avatar Devon Rifkin Committed by GitHub
Browse files

Merge pull request #11861 from ollama/drifkin/fix-parsing-error

server: fix error when parsing bad harmony tool calls
parents ea7657b5 ee04dbba
...@@ -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}}}
......
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