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 maxTokens to serve mode #1280

Merged
merged 8 commits into from
Nov 12, 2024
14 changes: 14 additions & 0 deletions cmd/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
defaultTemperature float32 = 0.7
defaultTopP float32 = 1.0
defaultTopK int32 = 50
defaultMaxTokens int = 2048
)

var (
Expand Down Expand Up @@ -102,6 +103,18 @@
}
return int32(topK)
}
maxTokens := func() int {
samirtahir91 marked this conversation as resolved.
Show resolved Hide resolved
env := os.Getenv("K8SGPT_MAX_TOKENS")
if env == "" {
return defaultMaxTokens
}
maxTokens, err := strconv.ParseInt(env, 10, 32)
if err != nil {
color.Red("Unable to convert maxTokens value: %v", err)
os.Exit(1)
}
return int(maxTokens)

Check warning on line 116 in cmd/serve/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/serve/serve.go#L106-L116

Added lines #L106 - L116 were not covered by tests
}
// Check for env injection
backend = os.Getenv("K8SGPT_BACKEND")
password := os.Getenv("K8SGPT_PASSWORD")
Expand All @@ -125,6 +138,7 @@
Temperature: temperature(),
TopP: topP(),
TopK: topK(),
MaxTokens: maxTokens(),

Check warning on line 141 in cmd/serve/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/serve/serve.go#L141

Added line #L141 was not covered by tests
}

configAI.Providers = append(configAI.Providers, *aiProvider)
Expand Down
Loading