fix ollama stream response unmarshall error

fix ollama stream response body unmarshall error
This commit is contained in:
glc-coder 2024-07-31 00:01:12 +08:00 committed by GitHub
parent c936198ac8
commit 3db8eb6de3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -119,7 +119,9 @@ func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusC
for scanner.Scan() {
data := strings.TrimPrefix(scanner.Text(), "}")
if !strings.HasSuffix(data, "}") {
data = data + "}"
}
var ollamaResponse ChatResponse
err := json.Unmarshal([]byte(data), &ollamaResponse)