Parcourir la source

fix: xAI missing finish_reason #572

CalciumIon il y a 1 an
Parent
commit
1774be8536
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      relay/channel/openai/relay-openai.go

+ 5 - 0
relay/channel/openai/relay-openai.go

@@ -98,6 +98,11 @@ func OaiStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon.Rel
 				shouldSendLastResp = false
 			}
 		}
+		for _, choice := range lastStreamResponse.Choices {
+			if choice.FinishReason != nil {
+				shouldSendLastResp = true
+			}
+		}
 	}
 	if shouldSendLastResp {
 		service.StringData(c, lastStreamData)