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

feat(cody-gateway): Add FLAGGED_MODEL_NAMES check#63013

Merged
chrsmith merged 3 commits intomainfrom
chrsmith/flag-based-on-llm-model
May 31, 2024
Merged

feat(cody-gateway): Add FLAGGED_MODEL_NAMES check#63013
chrsmith merged 3 commits intomainfrom
chrsmith/flag-based-on-llm-model

Conversation

@chrsmith
Copy link
Contributor

Cody Gateway may "flag" a request as a way to either identify clearly abusive traffic, and reject it before it reaches an LLM, or to allow for further analysis.

This PR adds the ability to specify a set of model names, and Cody Gateway will in-turn flag all requests for that specific model. This adds another knob for being able to identify abusive behavior and/or confirm that any sudden spikes in a particular LLM model are for legitimate reasons.

With this PR no "default" is provided. And a follow-up PR will need to be made in the infrastructure repo to add model names as applicable.

Test plan

Updated existing unit tests.

Changelog

Add a FLAGGED_MODEL_NAMES env var for Cody Gateway. Any requests using a supplied model will be flagged.

@chrsmith chrsmith requested review from a team and chenkc805 May 31, 2024 18:54
@cla-bot cla-bot bot added the cla-signed label May 31, 2024
Co-authored-by: Quinn Slack <quinn@slack.org>

func TestIsFlaggedRequest(t *testing.T) {
validPreamble := "You are cody-gateway."
flaggedModelNames := []string{"dangerous-llm-model"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "expensive-llm-model" instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this is just a test file so ignore

@chrsmith chrsmith enabled auto-merge (squash) May 31, 2024 20:01
@chrsmith chrsmith merged commit c4b5c73 into main May 31, 2024
@chrsmith chrsmith deleted the chrsmith/flag-based-on-llm-model branch May 31, 2024 20:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants