Skip to content

Commit

Permalink
fix stop reason missing problem
Browse files Browse the repository at this point in the history
  • Loading branch information
linexjlin committed Mar 26, 2024
1 parent 8da53a6 commit b90aca6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions userCore.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,13 @@ func (u *UserCore) QueryGPT(ctx context.Context, txtChan chan string, messages [
txtChan <- response.Choices[0].Delta.Content
}
if response.Choices[0].FinishReason == "stop" {
close(txtChan)
fmt.Println("stop")
}
}
})
if err != nil {
fmt.Printf("ChatCompletionStream error: %v\n", err)
txtChan <- fmt.Sprintf("ChatCompletionStream error: %v\n", err)
close(txtChan)
return
}
close(txtChan)
}

0 comments on commit b90aca6

Please sign in to comment.