Skip to content

Commit

Permalink
server: only parse tool calls if tools are provided (ollama#5771)
Browse files Browse the repository at this point in the history
* server: only parse tool calls if tools are provided

* still set `resp.Message.Content`
  • Loading branch information
jmorganca authored Jul 18, 2024
1 parent b255445 commit 319fb1c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1385,9 +1385,12 @@ func (s *Server) ChatHandler(c *gin.Context) {
}

resp.Message.Content = sb.String()
if toolCalls, ok := m.parseToolCalls(sb.String()); ok {
resp.Message.ToolCalls = toolCalls
resp.Message.Content = ""

if len(req.Tools) > 0 {
if toolCalls, ok := m.parseToolCalls(sb.String()); ok {
resp.Message.ToolCalls = toolCalls
resp.Message.Content = ""
}
}

c.JSON(http.StatusOK, resp)
Expand Down

0 comments on commit 319fb1c

Please sign in to comment.