mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-18 16:34:31 +00:00
fix: resolve language toggle bug (issue #294)
Signed-off-by: Matthis <matthish29@gmail.com>
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user