diff --git a/pkg/llm/llm.go b/pkg/llm/llm.go index e248bba..91fb21d 100644 --- a/pkg/llm/llm.go +++ b/pkg/llm/llm.go @@ -21,6 +21,7 @@ import ( "io" "reflect" "strconv" + "strings" "sync" "time" @@ -407,6 +408,9 @@ func (c *cached) String(ctx context.Context, messages []string) (string, error) if err != nil { return "", err } + if strings.Trim(value, " \n\r\t") == "" { + return "", errors.New("empty response") // Gemini may occur this. + } // TODO: reduce copies. if err = c.kvStorage.Set(ctx, []byte(keyStr), []byte(value), 65*time.Minute); err != nil {