-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support for content filters in Azure OpenAI #22822
Comments
Hi @dkmiller, thanks for raising this enhancement request. I will track this request and try to implement it. For anyone needs this right now, I would recommend using azapi provider to deploy resource with preview API version. |
@liuwuliuyun TIL the terraform {
required_providers {
azapi = {
source = "azure/azapi"
version = "~> 1.8.0"
}
}
}
resource "azapi_resource" "no_moderation_policy" {
type = "Microsoft.CognitiveServices/accounts/raiPolicies@2023-06-01-preview"
name = "NoModerationPolicy"
parent_id = var.parent_id
schema_validation_enabled = false
body = jsonencode({
displayName = ""
properties = {
basePolicyName = "Microsoft.Default"
type = "UserManaged"
contentFilters = [
{ name = "hate", blocking = false, enabled = true, allowedContentLevel = "High", source = "Prompt" },
{ name = "sexual", blocking = false, enabled = true, allowedContentLevel = "High", source = "Prompt" },
{ name = "selfharm", blocking = false, enabled = true, allowedContentLevel = "High", source = "Prompt" },
{ name = "violence", blocking = false, enabled = true, allowedContentLevel = "High", source = "Prompt" },
{ name = "hate", blocking = false, enabled = true, allowedContentLevel = "High", source = "Completion" },
{ name = "sexual", blocking = false, enabled = true, allowedContentLevel = "High", source = "Completion" },
{ name = "selfharm", blocking = false, enabled = true, allowedContentLevel = "High", source = "Completion" },
{ name = "violence", blocking = false, enabled = true, allowedContentLevel = "High", source = "Completion" },
]
}
})
} |
hey @dkmiller Thanks for opening this issue. Taking a quick look into this one we're currently using API Version The SDK we use ( As such I've gone ahead and labelled this issue to indicate that it's blocked on the API Definitions becoming available - but once those are available then we can take a look into supporting this natively within the AzureRM Provider. Thanks! |
Thanks @tombuildsstuff! I'm kicking off a conversation with our contacts in Azure, will circle back as soon as there is an update. |
Hi @tombuildsstuff and @dkmiller ! |
It looks like 2023-05-01 is still being used. @liuwuliuyun Are you the right person to ask if there is any update on this enhancement? |
@dsoltz1 — sadly, to the best of my knowledge We have an open ask out to Azure to publish API schemas including content filters, after which Terraform can pick those up. cc @cenhao, who is also interested in this from Airbnb. |
@illgitthat, thanks for reaching out, I will comment in this thread once there is update on this issue. In the meanwhile, I would suggest using AzAPI provider for any resource in preview API. |
I'm getting following error:
|
@kamikaze you can't disable content filters entirely without first getting approval. Reference: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cpython-new |
Would it be possible to also activate async streaming mode via terraform? |
How to disable content flters and acticate async straming mode via Go SDK? |
@liuwuliuyun any updates given the new 2024-02-01 API release? Having azurerm support will make things like dependency management easier. |
Support 👍 |
Hi everyone, I would like to answer some questions in this thread by Q&A format. Q: How could we create content filter in AOAI now? Q: Where do we know which API version I should use and is there a stable version 2024-02-01 released? Q: Why not support preview versions of API here? Hope this helps~ |
|
Thanks below code worked for me
And passing the value from var.content_filter_name into var.rai_policy_name as below deployment config
|
@vjayarag the issue is not the ability to manage this via azapi its that we want azurerm support for multiple reasons including:
The latter issue is being seen today within my environment when using the 2023-06-01-preview API, given that preview APIs are mutable..... The naming convention for the categories (or names) seems to have changed and now are upper case for Hate, Sexual and Violence, where selfharm is still lower case. This type of churn causes a perpetual diff within our environment without us mutating anything on our end. This is extremely sub optimal. |
Hey @tombuildsstuff, I finally heard back from Microsoft! They've got an updated API version now GA at 2024-06-01. It should have all latest features including latest content filter annotations. Hopefully that should unblock implementing this feature request? |
@dkmiller: The API you linked is for Azure AI Services and does not include Cognitive Services Accounts -> raiPolicies. However! There is a new 2024-10-01 Cognitive Services API in stable which does: |
It also looks like this was included in hashicorp/go-azure-sdk last week as well: https://github.com/hashicorp/go-azure-sdk/tree/main/resource-manager/cognitive/2024-10-01 |
This is fantastic news! cc @qiaqiatic who is also at Airbnb and using the old "azapi" approach. |
@dkmiller instead of using microsoft.default can i use a custom filter and change the settings inside content filters? i tried updating the value and it throws an error "message": "Policy does not have necessary permission to override base policy. Please check aka.ms/oai/rai/exceptions" |
@NikhilKosare I suspect you need to be approved for content filter modifications here: https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xUMlBQNkZMR0lFRldORTdVQzQ0TEI5Q1ExOSQlQCN0PWcu per https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/content-filters |
Another potential reason for having true Azurerm support would be to eliminate this issue. Via azapi, I sporadically get this bug in case sensitive for the categories, but I have not figured out how to fix the perpetual diff. No matter what I supply to the API (along with trying different API versions), I get a diff due to case sensitivity. (apologies not sure why the code paste indentation is getting removed)
|
TL;DR: What's happening here?
How can I set
|
Hi, thank you for raising this issue, today we are relying on the AZAPI as above which does work but would love to be able to use a proper azrem for it. Is there a timeframe for this being migrated please? Thank you again for all the efforts here. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Is there an existing issue for this?
Community Note
Description
Azure OpenAI has introduced the ability to configure content filters (How to configure content filters with Azure OpenAI Service).
Terraform already supports specifying a custom policy name via
rai_policy_name
. However, it does not appear that Terraform currently supports creating custom policies.The underlying REST call made to create a new content filter is looks like below.
with a body like
New or Affected Resource(s)/Data Source(s)
azurerm_cognitive_rai_policy
Potential Terraform Configuration
References
RBAC docs for
Microsoft.CognitiveServices/accounts/raiPolicies/*
: https://learn.microsoft.com/en-us/azure/role-based-access-control/resource-provider-operationsOriginal, incorrectly-filed, issue: Azure/terraform-azurerm-openai#28.
The text was updated successfully, but these errors were encountered: