diff --git a/lib/tgspam/openai.go b/lib/tgspam/openai.go index d87ce26..0a9fb76 100644 --- a/lib/tgspam/openai.go +++ b/lib/tgspam/openai.go @@ -144,7 +144,7 @@ func (o *openAIChecker) sendRequest(msg string) (response openAIResponse, err er } if err := json.Unmarshal([]byte(resp.Choices[0].Message.Content), &response); err != nil { - return openAIResponse{}, fmt.Errorf("can't unmarshal response: %w", err) + return openAIResponse{}, fmt.Errorf("can't unmarshal response: %s - %w", resp.Choices[0].Message.Content, err) } return response, nil diff --git a/lib/tgspam/openai_test.go b/lib/tgspam/openai_test.go index 90cff84..83789cd 100644 --- a/lib/tgspam/openai_test.go +++ b/lib/tgspam/openai_test.go @@ -90,8 +90,10 @@ func TestOpenAIChecker_Check(t *testing.T) { t.Logf("spam: %v, details: %+v", spam, details) assert.False(t, spam) assert.Equal(t, "openai", details.Name) - assert.Equal(t, "OpenAI error: can't unmarshal response: invalid character 'b' looking for beginning of value", details.Details) - assert.Equal(t, "can't unmarshal response: invalid character 'b' looking for beginning of value", details.Error.Error()) + assert.Equal(t, "OpenAI error: can't unmarshal response: bad json - invalid character 'b' looking for beginning of value", + details.Details) + assert.Equal(t, "can't unmarshal response: bad json - invalid character 'b' looking for beginning of value", + details.Error.Error()) }) t.Run("no choices", func(t *testing.T) {