-
Notifications
You must be signed in to change notification settings - Fork 352
feat(azure.ai.agents): add invocationsModeration to RAI policies #9596
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
563931e
af5c48d
a594358
34e1714
5144722
478cb5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
| "maps" | ||
| "math" | ||
| "regexp" | ||
| "slices" | ||
| "strings" | ||
|
|
||
| "azureaiagent/internal/pkg/agents/agent_api" | ||
|
|
@@ -91,12 +92,41 @@ func constructBuildConfig(options ...AgentBuildOption) *AgentBuildConfig { | |
| func mapRaiConfig(policies []Policy) *agent_api.RaiConfig { | ||
| for _, policy := range policies { | ||
| if policy.Type == PolicyTypeRai && policy.RaiPolicyName != "" { | ||
| return &agent_api.RaiConfig{RaiPolicyName: policy.RaiPolicyName} | ||
| return &agent_api.RaiConfig{ | ||
| RaiPolicyName: policy.RaiPolicyName, | ||
| InvocationsModeration: mapInvocationsModeration(policy.InvocationsModeration), | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the first named
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valid —
Consistent with the rest of this PR's fail-fast-locally approach. Covered by Happy to narrow it to "only reject when a second policy carries |
||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // mapInvocationsModeration translates the YAML invocations-moderation block into its | ||
| // data-plane representation. It returns nil when the block is absent so agents that do not | ||
| // configure it serialize exactly as before. | ||
| func mapInvocationsModeration(moderation *InvocationsModeration) *agent_api.InvocationsModeration { | ||
| if moderation == nil { | ||
| return nil | ||
| } | ||
|
|
||
| mapped := &agent_api.InvocationsModeration{ | ||
| InputContentType: agent_api.RaiInvocationContentType(moderation.InputContentType), | ||
| OutputContentType: agent_api.RaiInvocationContentType(moderation.OutputContentType), | ||
| ResponseMode: agent_api.RaiInvocationMode(moderation.ResponseMode), | ||
| InputPaths: slices.Clone(moderation.InputPaths), | ||
| OutputPaths: slices.Clone(moderation.OutputPaths), | ||
| } | ||
|
|
||
| for _, selector := range moderation.StreamSelectors { | ||
| mapped.StreamSelectors = append(mapped.StreamSelectors, agent_api.SseTextSelector{ | ||
| EventType: selector.EventType, | ||
| TextField: selector.TextField, | ||
| }) | ||
| } | ||
|
|
||
| return mapped | ||
| } | ||
|
|
||
| // MapEndpointAndCard maps YAML-layer endpoint and card fields to API model types | ||
| // without requiring or validating the full agent definition. This is used by the | ||
| // endpoint update command where only endpoint/card patching is needed. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.