Skip to content

Commit 61548e8

Browse files
committed
Fix log message for empty API response and reorder message appending
1 parent a5ea767 commit 61548e8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/router/chat.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ func SendMessage(client *openai.Client, messages *[]ChatCompletionMessage, myBot
104104
log.Fatalf("Error creating follow-up chat completion: %v", finalErr)
105105
}
106106

107-
*messages = append(*messages, finalResp.Choices[0].Message)
108-
109107
if len(finalResp.Choices) == 0 {
110-
log.Println("received an empty response from API, trying again")
111-
return "", fmt.Errorf("received an empty response from API")
108+
log.Println("received an empty response from openRouter, trying again")
109+
return "", fmt.Errorf("received an empty response from openRouter")
112110
}
113111

112+
*messages = append(*messages, finalResp.Choices[0].Message)
113+
114114
choice = finalResp.Choices[0]
115115

116116
if choice.FinishReason == openai.FinishReasonToolCalls {

0 commit comments

Comments
 (0)