瀏覽代碼

server: only parse tool calls if tools are provided (#5771)

* server: only parse tool calls if tools are provided

* still set `resp.Message.Content`
Jeffrey Morgan 9 月之前
父節點
當前提交
319fb1ce03
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      server/routes.go

+ 6 - 3
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)