Skip to content

Commit

Permalink
fix: add providerId, maxTokens and topk to ai spec (#545)
Browse files Browse the repository at this point in the history
Signed-off-by: samir-tahir <[email protected]>
  • Loading branch information
samirtahir91 authored Dec 2, 2024
1 parent eaf6456 commit 771acbe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha1/k8sgpt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ type AISpec struct {
// +kubebuilder:default:=english
Language string `json:"language,omitempty"`
ProxyEndpoint string `json:"proxyEndpoint,omitempty"`
ProviderId string `json:"providerId,omitempty"`
// +kubebuilder:default:="2048"
MaxTokens string `json:"maxTokens,omitempty"`
// +kubebuilder:default:="50"
Topk string `json:"topk,omitempty"`
}

type Trivy struct {
Expand Down
8 changes: 8 additions & 0 deletions chart/operator/templates/k8sgpt-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ spec:
language:
default: english
type: string
maxTokens:
default: "2048"
type: string
model:
default: gpt-3.5-turbo
type: string
providerId:
type: string
proxyEndpoint:
type: string
region:
Expand All @@ -89,6 +94,9 @@ spec:
name:
type: string
type: object
topk:
default: "50"
type: string
required:
- backend
type: object
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ spec:
language:
default: english
type: string
maxTokens:
default: "2048"
type: string
model:
default: gpt-3.5-turbo
type: string
providerId:
type: string
proxyEndpoint:
type: string
region:
Expand All @@ -92,6 +97,9 @@ spec:
name:
type: string
type: object
topk:
default: "50"
type: string
required:
- backend
type: object
Expand Down
19 changes: 19 additions & 0 deletions pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ func GetDeployment(config v1alpha1.K8sGPT, outOfClusterMode bool, c client.Clien
Name: "K8SGPT_BACKEND",
Value: config.Spec.AI.Backend,
},
{
Name: "K8SGPT_MAX_TOKENS",
Value: config.Spec.AI.MaxTokens,
},
{
Name: "K8SGPT_TOP_K",
Value: config.Spec.AI.Topk,
},
{
Name: "XDG_CONFIG_HOME",
Value: "/k8sgpt-data/.config",
Expand Down Expand Up @@ -271,6 +279,17 @@ func GetDeployment(config v1alpha1.K8sGPT, outOfClusterMode bool, c client.Clien
}
}

// Add provider ID if in ai spec
if config.Spec.AI.ProviderId != "" {
providerId := corev1.EnvVar{
Name: "K8SGPT_PROVIDER_ID",
Value: config.Spec.AI.ProviderId,
}
deployment.Spec.Template.Spec.Containers[0].Env = append(
deployment.Spec.Template.Spec.Containers[0].Env, providerId,
)
}

if config.Spec.AI.BaseUrl != "" {
baseUrl := corev1.EnvVar{
Name: "K8SGPT_BASEURL",
Expand Down

0 comments on commit 771acbe

Please sign in to comment.