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

feat: Add content filtering with convenience functions #58

Merged
merged 49 commits into from
Aug 13, 2024

Conversation

KavithaSiva
Copy link
Contributor

@KavithaSiva KavithaSiva commented Aug 7, 2024

Proposed state:

client.chatCompletion({
  deploymentConfiguration: { deploymentId: 'id' },
  llmConfig: {
    model_name: 'gpt-35-turbo-16k',
    model_params: { max_tokens: 50, temperature: 0.1 }
  },
  prompt: {
    template: [{ role: 'user', content: 'What is the capital of Germany?' }]
  },
  filterConfig: {
    input: azureContentFilter({ Hate: 4, SelfHarm: 2 }),
    output: azureContentFilter({ Sexual: 0, Violence: 6 })
  }
});

or you could assign filterConfig property with the content filtering JSON structure the orchestration service accepts:

client.chatCompletion({
  deploymentConfiguration: { deploymentId: 'id' },
  llmConfig: {
    model_name: 'gpt-35-turbo-16k',
    model_params: { max_tokens: 50, temperature: 0.1 }
  },
  prompt: {
    template: [{ role: 'user', content: 'What is the capital of Germany?' }]
  },
  filterConfig: {
    input: {
      filters: [
        {
          type: 'azure_content_safety',
          config: {
            Hate: 4,
            SelfHarm: 4,
            Sexual: 4,
            Violence: 4
          }
        }
      ]
    },
    output: {
      filters: [
        {
          type: 'azure_content_safety',
          config: {
            Hate: 0,
            SelfHarm: 2,
            Sexual: 2,
            Violence: 2
          }
        }
      ]
    }
  }
});

Note: I also re-generated the orchestration client.

@KavithaSiva KavithaSiva marked this pull request as draft August 8, 2024 14:46
@KavithaSiva KavithaSiva marked this pull request as ready for review August 9, 2024 13:26
Copy link
Member

@MatKuhr MatKuhr left a comment

Choose a reason for hiding this comment

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

LGTM!
Nice that we have the test coverage and also the option for the default filter, where no config is given.
Maybe someone else wants to look more closely at the TS coding details, but semantically it makes sense to me 👍🏻

Copy link
Contributor

@marikaner marikaner left a comment

Choose a reason for hiding this comment

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

I like the outcome. I think it makes sense to allow both variants and the convenient variant is easy to consume. One thing to consider in the future is, if discoverability can be improved when there are multiple services in orchestration.

@KavithaSiva KavithaSiva merged commit 5bf34b5 into main Aug 13, 2024
10 checks passed
@KavithaSiva KavithaSiva deleted the feat/add-content-filtering-with-functions branch August 13, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants