From 319fb1ce033921b70685abce0b2e06f52304fe74 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 18 Jul 2024 08:50:23 -0700 Subject: [PATCH] server: only parse tool calls if tools are provided (#5771) * server: only parse tool calls if tools are provided * still set `resp.Message.Content` --- server/routes.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/routes.go b/server/routes.go index b4a8b4ac..347d5221 100644 --- a/server/routes.go +++ b/server/routes.go @@ -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)