mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-07-04 02:56:24 +00:00
Merge pull request #296 from matthisholleville/fix/language-toggle-bug
fix: resolve language toggle bug (issue #294)
This commit is contained in:
commit
a962d13654
@ -4,10 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
|
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NoOpAIClient struct {
|
type NoOpAIClient struct {
|
||||||
@ -34,7 +35,7 @@ func (a *NoOpAIClient) Parse(ctx context.Context, prompt []string, nocache bool)
|
|||||||
inputKey := strings.Join(prompt, " ")
|
inputKey := strings.Join(prompt, " ")
|
||||||
// Check for cached data
|
// Check for cached data
|
||||||
sEnc := base64.StdEncoding.EncodeToString([]byte(inputKey))
|
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)
|
response, err := a.GetCompletion(ctx, inputKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -5,9 +5,10 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ func (a *OpenAIClient) Parse(ctx context.Context, prompt []string, nocache bool)
|
|||||||
inputKey := strings.Join(prompt, " ")
|
inputKey := strings.Join(prompt, " ")
|
||||||
// Check for cached data
|
// Check for cached data
|
||||||
sEnc := base64.StdEncoding.EncodeToString([]byte(inputKey))
|
sEnc := base64.StdEncoding.EncodeToString([]byte(inputKey))
|
||||||
cacheKey := util.GetCacheKey(a.GetName(), sEnc)
|
cacheKey := util.GetCacheKey(a.GetName(), a.language, sEnc)
|
||||||
// find in viper cache
|
// find in viper cache
|
||||||
if viper.IsSet(cacheKey) && !nocache {
|
if viper.IsSet(cacheKey) && !nocache {
|
||||||
// retrieve data from cache
|
// retrieve data from cache
|
||||||
|
@ -134,8 +134,8 @@ func ReplaceIfMatch(text string, pattern string, replacement string) string {
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCacheKey(provider string, sEnc string) string {
|
func GetCacheKey(provider string, language string, sEnc string) string {
|
||||||
return fmt.Sprintf("%s-%s", provider, sEnc)
|
return fmt.Sprintf("%s-%s-%s", provider, language, sEnc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPodListByLabels(client k.Interface,
|
func GetPodListByLabels(client k.Interface,
|
||||||
|
Loading…
Reference in New Issue
Block a user