Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 3e8a830

Browse files
authored
Remove code for logging completions (#60372)
1 parent e321ee2 commit 3e8a830

File tree

5 files changed

+5
-36
lines changed

5 files changed

+5
-36
lines changed

cmd/cody-gateway/internal/httpapi/completions/anthropic.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/grafana/regexp"
1111
"github.com/sourcegraph/log"
12-
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/internal/actor"
1312
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/shared/config"
1413
"github.com/sourcegraph/sourcegraph/internal/completions/client/anthropic"
1514

@@ -226,7 +225,7 @@ func (a *AnthropicHandlerMethods) transformBody(body *anthropicRequest, identifi
226225
UserID: identifier,
227226
}
228227
}
229-
func (a *AnthropicHandlerMethods) getRequestMetadata(_ context.Context, _ log.Logger, _ *actor.Actor, _ codygateway.Feature, body anthropicRequest) (model string, additionalMetadata map[string]any) {
228+
func (a *AnthropicHandlerMethods) getRequestMetadata(body anthropicRequest) (model string, additionalMetadata map[string]any) {
230229
return body.Model, map[string]any{
231230
"stream": body.Stream,
232231
"max_tokens_to_sample": body.MaxTokensToSample,

cmd/cody-gateway/internal/httpapi/completions/fireworks.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/sourcegraph/log"
1212
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/shared/config"
1313

14-
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/internal/actor"
1514
"github.com/sourcegraph/sourcegraph/internal/completions/client/fireworks"
1615

1716
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/internal/events"
@@ -135,33 +134,7 @@ func (f *FireworksHandlerMethods) transformBody(body *fireworksRequest, _ string
135134
body.Model = pickModelBasedOnTrafficSplit(f.config.StarcoderCommunitySingleTenantPercent, fireworks.Starcoder16bSingleTenant, multiTenantModel)
136135
}
137136
}
138-
func (f *FireworksHandlerMethods) getRequestMetadata(ctx context.Context, logger log.Logger, act *actor.Actor, feature codygateway.Feature, body fireworksRequest) (model string, additionalMetadata map[string]any) {
139-
// Check that this is a code completion request and that the actor is a PLG user
140-
if feature == codygateway.FeatureCodeCompletions && f.config.LogSelfServeCodeCompletionRequests && act.IsDotComActor() {
141-
// LogEvent is a channel send (not an external request), so should be ok here
142-
if err := f.eventLogger.LogEvent(
143-
ctx,
144-
events.Event{
145-
Name: codygateway.EventNameCodeCompletionLogged,
146-
Source: act.Source.Name(),
147-
Identifier: act.ID,
148-
Metadata: map[string]any{
149-
"request": map[string]any{
150-
"prompt": body.Prompt,
151-
"model": body.Model,
152-
"max_tokens": body.MaxTokens,
153-
"temperature": body.Temperature,
154-
"top_p": body.TopP,
155-
"n": body.N,
156-
"stream": body.Stream,
157-
"echo": body.Echo,
158-
"stop": body.Stop,
159-
},
160-
},
161-
}); err != nil {
162-
logger.Error("failed to log event", log.Error(err))
163-
}
164-
}
137+
func (f *FireworksHandlerMethods) getRequestMetadata(body fireworksRequest) (model string, additionalMetadata map[string]any) {
165138
return body.Model, map[string]any{"stream": body.Stream}
166139
}
167140
func (f *FireworksHandlerMethods) transformRequest(r *http.Request) {

cmd/cody-gateway/internal/httpapi/completions/openai.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/sourcegraph/log"
1111
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/shared/config"
1212

13-
"github.com/sourcegraph/sourcegraph/cmd/cody-gateway/internal/actor"
1413
"github.com/sourcegraph/sourcegraph/internal/completions/client/openai"
1514
"github.com/sourcegraph/sourcegraph/lib/errors"
1615

@@ -127,7 +126,7 @@ func (_ *OpenAIHandlerMethods) transformBody(body *openaiRequest, identifier str
127126
// We forward the actor ID to support tracking.
128127
body.User = identifier
129128
}
130-
func (_ *OpenAIHandlerMethods) getRequestMetadata(_ context.Context, _ log.Logger, _ *actor.Actor, _ codygateway.Feature, body openaiRequest) (model string, additionalMetadata map[string]any) {
129+
func (_ *OpenAIHandlerMethods) getRequestMetadata(body openaiRequest) (model string, additionalMetadata map[string]any) {
131130
return body.Model, map[string]any{"stream": body.Stream}
132131
}
133132

cmd/cody-gateway/internal/httpapi/completions/upstream.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type upstreamHandlerMethods[ReqT UpstreamRequest] interface {
7979
// to be reported here - instead, use parseResponseAndUsage to extract usage,
8080
// which for some providers we can only know after the fact based on what
8181
// upstream tells us.
82-
getRequestMetadata(context.Context, log.Logger, *actor.Actor, codygateway.Feature, ReqT) (model string, additionalMetadata map[string]any)
82+
getRequestMetadata(ReqT) (model string, additionalMetadata map[string]any)
8383
// parseResponseAndUsage should extract details from the response we get back from
8484
// upstream as well as overall usage for tracking purposes.
8585
//
@@ -247,7 +247,7 @@ func makeUpstreamHandler[ReqT UpstreamRequest](
247247
methods.transformRequest(req)
248248

249249
// Retrieve metadata from the initial request.
250-
model, requestMetadata := methods.getRequestMetadata(r.Context(), logger, act, feature, body)
250+
model, requestMetadata := methods.getRequestMetadata(body)
251251

252252
// Match the model against the allowlist of models, which are configured
253253
// with the Cody Gateway model format "$PROVIDER/$MODEL_NAME". Models

cmd/cody-gateway/shared/config/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ type AnthropicConfig struct {
7676
type FireworksConfig struct {
7777
AllowedModels []string
7878
AccessToken string
79-
LogSelfServeCodeCompletionRequests bool
8079
StarcoderCommunitySingleTenantPercent int
8180
StarcoderEnterpriseSingleTenantPercent int
8281
}
@@ -161,7 +160,6 @@ func (c *Config) Load() {
161160
"accounts/fireworks/models/mixtral-8x7b-instruct",
162161
}, ","),
163162
"Fireworks models that can be used."))
164-
c.Fireworks.LogSelfServeCodeCompletionRequests = c.GetBool("CODY_GATEWAY_FIREWORKS_LOG_SELF_SERVE_COMPLETION_REQUESTS", "false", "Whether we should log self-serve code completion requests.")
165163
if c.Fireworks.AccessToken != "" && len(c.Fireworks.AllowedModels) == 0 {
166164
c.AddError(errors.New("must provide allowed models for Fireworks"))
167165
}

0 commit comments

Comments
 (0)