Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add providerId, maxTokens and topk to ai spec #545

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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