Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Llm empty response fix #423

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions chipper/pkg/wirepod/ttr/kgsim.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func StreamingKGSim(req interface{}, esn string, transcribedText string, isKG bo

stream, err := c.CreateChatCompletionStream(ctx, aireq)
if err != nil {
log.Printf("Error creating chat completion stream: %v", err)
if strings.Contains(err.Error(), "does not exist") && vars.APIConfig.Knowledge.Provider == "openai" {
logger.Println("GPT-4 model cannot be accessed with this API key. You likely need to add more than $5 dollars of funds to your OpenAI account.")
logger.LogUI("GPT-4 model cannot be accessed with this API key. You likely need to add more than $5 dollars of funds to your OpenAI account.")
Expand Down Expand Up @@ -344,6 +345,11 @@ func StreamingKGSim(req interface{}, esn string, transcribedText string, isKG bo
return
}

if (len(response.Choices) == 0) {
logger.Println("Empty response")
return
}

fullfullRespText = fullfullRespText + removeSpecialCharacters(response.Choices[0].Delta.Content)
fullRespText = fullRespText + removeSpecialCharacters(response.Choices[0].Delta.Content)
if strings.Contains(fullRespText, "...") || strings.Contains(fullRespText, ".'") || strings.Contains(fullRespText, ".\"") || strings.Contains(fullRespText, ".") || strings.Contains(fullRespText, "?") || strings.Contains(fullRespText, "!") {
Expand Down
Loading