diff --git a/pkg/ai/noopai.go b/pkg/ai/noopai.go index 8ea24d8516..9f17e569d9 100644 --- a/pkg/ai/noopai.go +++ b/pkg/ai/noopai.go @@ -4,10 +4,11 @@ import ( "context" "encoding/base64" "fmt" + "strings" + "github.com/fatih/color" "github.com/k8sgpt-ai/k8sgpt/pkg/util" "github.com/spf13/viper" - "strings" ) type NoOpAIClient struct { @@ -34,7 +35,7 @@ func (a *NoOpAIClient) Parse(ctx context.Context, prompt []string, nocache bool) inputKey := strings.Join(prompt, " ") // Check for cached data sEnc := base64.StdEncoding.EncodeToString([]byte(inputKey)) - cacheKey := util.GetCacheKey(a.GetName(), sEnc) + cacheKey := util.GetCacheKey(a.GetName(), a.language, sEnc) response, err := a.GetCompletion(ctx, inputKey) if err != nil { diff --git a/pkg/ai/openai.go b/pkg/ai/openai.go index 4ffca36506..f35bcbad01 100644 --- a/pkg/ai/openai.go +++ b/pkg/ai/openai.go @@ -5,9 +5,10 @@ import ( "encoding/base64" "errors" "fmt" - "github.com/k8sgpt-ai/k8sgpt/pkg/util" "strings" + "github.com/k8sgpt-ai/k8sgpt/pkg/util" + "github.com/fatih/color" "github.com/spf13/viper" @@ -59,7 +60,7 @@ func (a *OpenAIClient) Parse(ctx context.Context, prompt []string, nocache bool) inputKey := strings.Join(prompt, " ") // Check for cached data sEnc := base64.StdEncoding.EncodeToString([]byte(inputKey)) - cacheKey := util.GetCacheKey(a.GetName(), sEnc) + cacheKey := util.GetCacheKey(a.GetName(), a.language, sEnc) // find in viper cache if viper.IsSet(cacheKey) && !nocache { // retrieve data from cache diff --git a/pkg/util/util.go b/pkg/util/util.go index 023b77318f..5c74da7163 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -134,8 +134,8 @@ func ReplaceIfMatch(text string, pattern string, replacement string) string { return text } -func GetCacheKey(provider string, sEnc string) string { - return fmt.Sprintf("%s-%s", provider, sEnc) +func GetCacheKey(provider string, language string, sEnc string) string { + return fmt.Sprintf("%s-%s-%s", provider, language, sEnc) } func GetPodListByLabels(client k.Interface,