Cody Gateway: remove feature flag requirement for Gemini models (#63055)

Cody Gateway: add google/gemini-1.5-pro-latest and google/gemini-1.5-flash-latest to allowed models

This change adds the Google Gemini 1.5 Pro and Flash models to the list of allowed models for Cody Gateway chat completions by default without requiring "cody-pro-gemini-enabled". This allows Cody Pro users to access these models.

The changes were made in the following files:
- `cmd/frontend/internal/dotcom/productsubscription/codygateway_dotcom_user.go`
- `internal/licensing/codygateway.go`
- `internal/licensing/codygateway_test.go`
This commit is contained in:
Beatrix 2024-06-04 07:15:35 -07:00 committed by GitHub
parent a5699594f2
commit 03f5866380
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -246,7 +246,7 @@ func getCompletionsRateLimit(ctx context.Context, db database.DB, userID int32,
if featureflag.FromContext(ctx).GetBoolOr("rate-limits-exceeded-for-testing", false) {
return licensing.CodyGatewayRateLimit{
// For this special tester user, just allow all models a Pro user can get.
AllowedModels: allowedModels(scope, true, false),
AllowedModels: allowedModels(scope, true),
Limit: 1,
IntervalSeconds: math.MaxInt32,
}, graphqlbackend.CodyGatewayRateLimitSourceOverride, nil
@ -279,7 +279,7 @@ func getCompletionsRateLimit(ctx context.Context, db database.DB, userID int32,
if err != nil {
return licensing.CodyGatewayRateLimit{}, graphqlbackend.CodyGatewayRateLimitSourcePlan, errors.Wrap(err, "error fetching user's cody subscription")
}
models := allowedModels(scope, true, featureflag.FromContext(ctx).GetBoolOr("cody-pro-gemini-enabled", false))
models := allowedModels(scope, true)
if limit == nil && cfg != nil {
source = graphqlbackend.CodyGatewayRateLimitSourcePlan
// Update the allowed models based on the user's plan.
@ -355,7 +355,7 @@ var allCodeCompletionModels = slices.Concat([]string{"anthropic/" + anthropic.Cl
prefix("fireworks/", fireworks.FineTunedMixtralModelVariants),
prefix("fireworks/", fireworks.FineTunedLlamaModelVariants))
func allowedModels(scope types.CompletionsFeature, isProUser bool, googleGeminiEnabled bool) []string {
func allowedModels(scope types.CompletionsFeature, isProUser bool) []string {
switch scope {
case types.CompletionsFeatureChat:
// When updating the below lists, make sure you also update `isAllowedCustomChatModel` in `chat.go`
@ -382,6 +382,8 @@ func allowedModels(scope types.CompletionsFeature, isProUser bool, googleGeminiE
"openai/gpt-4o",
"openai/gpt-4-turbo",
"openai/gpt-4-turbo-preview",
"google/gemini-1.5-pro-latest",
"google/gemini-1.5-flash-latest",
// Remove after the Claude 3 rollout is complete
"anthropic/claude-2",
@ -392,9 +394,6 @@ func allowedModels(scope types.CompletionsFeature, isProUser bool, googleGeminiE
"anthropic/claude-instant-v1",
"anthropic/claude-instant-1",
}
if googleGeminiEnabled {
chatModels = append(chatModels, "google/gemini-1.5-pro-latest", "google/gemini-1.5-flash-latest")
}
return chatModels
case types.CompletionsFeatureCode:

View File

@ -47,6 +47,9 @@ func NewCodyGatewayChatRateLimit(plan Plan, userCount *int) CodyGatewayRateLimit
"openai/gpt-4o",
"openai/gpt-4-turbo",
"openai/gpt-4-turbo-preview",
"google/gemini-1.5-pro-latest",
"google/gemini-1.5-flash-latest",
}
switch plan {
// TODO: This is just an example for now.

View File

@ -36,6 +36,8 @@ func TestNewCodyGatewayChatRateLimit(t *testing.T) {
"openai/gpt-4o",
"openai/gpt-4-turbo",
"openai/gpt-4-turbo-preview",
"google/gemini-1.5-pro-latest",
"google/gemini-1.5-flash-latest",
},
Limit: 2500,
IntervalSeconds: 60 * 60 * 24,
@ -61,6 +63,8 @@ func TestNewCodyGatewayChatRateLimit(t *testing.T) {
"openai/gpt-4o",
"openai/gpt-4-turbo",
"openai/gpt-4-turbo-preview",
"google/gemini-1.5-pro-latest",
"google/gemini-1.5-flash-latest",
},
Limit: 50,
IntervalSeconds: 60 * 60 * 24,
@ -86,6 +90,8 @@ func TestNewCodyGatewayChatRateLimit(t *testing.T) {
"openai/gpt-4o",
"openai/gpt-4-turbo",
"openai/gpt-4-turbo-preview",
"google/gemini-1.5-pro-latest",
"google/gemini-1.5-flash-latest",
},
Limit: 10,
IntervalSeconds: 60 * 60 * 24,