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

Cody Gateway flags all requests to Google models #63294

@vdavid

Description

@vdavid

Problem:
@toolmantim's account was banned (related thread)

Link: https://sourcegraph.com/users/toolmantim/settings/quota
ID: 59727 / 018d5660-4043-745d-bc0d-ca8e69970468

Findings:

  • In the past week, 100% of Tim’s chat requests were flagged where he used a Google model, and 0 other requests were flagged (58 flagged out of 77 requests).
  • All flagged requests had both the high_max_tokens_to_sample and blocked_phrase flags, and no other.

Based on this code, not having a tokenizer avoids the high_prompt_token_count flag, and indeed, no requests got that one. Only the high_max_tokens_to_sample and blocked_phrase are applied, but those are enough for the request to be flagged all the same.

Redash queries that helped me:

Solution ideas:

  1. If we wanted to just do no flagging for Google requests, we could do
func (g *GoogleHandlerMethods) shouldFlagRequest(_ context.Context, _ log.Logger, _ googleRequest) (*flaggingResult, error) {
    // This entirely disables flagging for Google requests.
	result := flaggingResult{
		shouldBlock:       false,
		blockedPhrase:     nil,
		reasons:           nil,
		promptPrefix:      "",
		maxTokensToSample: 0,
		promptTokenCount:  0,
	}
	return &result, nil
}
  1. Investigate why this happens, and go with a softer measure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions