Log OpenAI error to debug log for #167

This commit is contained in:
David Dworken 2024-02-05 21:34:03 -08:00
parent a6333ea995
commit d27c3cd8e4
No known key found for this signature in database
2 changed files with 2 additions and 1 deletions

View File

@ -496,6 +496,7 @@ func renderNullableTable(m model, helpText string) string {
func getRowsFromAiSuggestions(ctx context.Context, columnNames []string, query string) ([]table.Row, []*data.HistoryEntry, error) {
suggestions, err := ai.DebouncedGetAiSuggestions(ctx, strings.TrimPrefix(query, "?"), 5)
if err != nil {
hctx.GetLogger().Infof("failed to get AI query suggestions: %v", err)
return nil, nil, fmt.Errorf("failed to get AI query suggestions: %w", err)
}
var rows []table.Row

View File

@ -103,7 +103,7 @@ func GetAiSuggestionsViaOpenAiApi(query, shellName, osName string, numberComplet
return nil, OpenAiUsage{}, fmt.Errorf("failed to parse OpenAI API response=%#v: %w", bodyText, err)
}
if len(apiResp.Choices) == 0 {
return nil, OpenAiUsage{}, fmt.Errorf("OpenAI API returned zero choices, parsed resp=%#v, resp body=%#v", apiResp, bodyText)
return nil, OpenAiUsage{}, fmt.Errorf("OpenAI API returned zero choices, parsed resp=%#v, resp body=%#v, resp.StatusCode=%d", apiResp, bodyText, resp.StatusCode)
}
ret := make([]string, 0)
for _, item := range apiResp.Choices {