-
Notifications
You must be signed in to change notification settings - Fork 10
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 descriptive enum constant for Azure content filter configuration - Option 2 #476
Changes from all commits
c7e9120
5bc8251
9e44509
32d48dd
3b15096
49b385d
ccf71ab
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,7 +8,9 @@ export type { | |
StreamOptions, | ||
DocumentGroundingServiceConfig, | ||
DocumentGroundingServiceFilter, | ||
LlmModelParams | ||
LlmModelParams, | ||
AzureContentSafety, | ||
AzureFilterThreshold | ||
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. [req] Why are we not directly overriding |
||
} from './orchestration-types.js'; | ||
|
||
export { OrchestrationStreamResponse } from './orchestration-stream-response.js'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { | |
constructCompletionPostRequestFromJsonModuleConfig | ||
} from './orchestration-utils.js'; | ||
import { OrchestrationResponse } from './orchestration-response.js'; | ||
import { AzureFilterThreshold } from './orchestration-types.js'; | ||
import type { CompletionPostResponse } from './client/api/schema/index.js'; | ||
import type { | ||
OrchestrationModuleConfig, | ||
|
@@ -162,8 +163,14 @@ describe('orchestration service client', () => { | |
] | ||
}, | ||
filtering: { | ||
input: buildAzureContentFilter({ Hate: 4, SelfHarm: 2 }), | ||
output: buildAzureContentFilter({ Sexual: 0, Violence: 4 }) | ||
input: buildAzureContentFilter({ | ||
Hate: AzureFilterThreshold.ALLOW_SAFE_LOW_MEDIUM, | ||
SelfHarm: AzureFilterThreshold.ALLOW_SAFE_LOW | ||
}), | ||
output: buildAzureContentFilter({ | ||
Sexual: AzureFilterThreshold.ALLOW_SAFE, | ||
Violence: AzureFilterThreshold.ALLOW_SAFE_LOW_MEDIUM | ||
}) | ||
Comment on lines
+166
to
+173
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. Also here, don't change the test. Add a new one (or type test). |
||
} | ||
}; | ||
const prompt = { | ||
|
@@ -210,21 +217,21 @@ describe('orchestration service client', () => { | |
input: { | ||
filters: [ | ||
{ | ||
type: 'azure_content_safety' as const, | ||
type: 'azure_content_safety', | ||
config: { | ||
Hate: 4 as const, | ||
SelfHarm: 2 as const | ||
Hate: 4, | ||
SelfHarm: 2 | ||
} | ||
} | ||
] | ||
}, | ||
output: { | ||
filters: [ | ||
{ | ||
type: 'azure_content_safety' as const, | ||
type: 'azure_content_safety', | ||
config: { | ||
Sexual: 0 as const, | ||
Violence: 4 as const | ||
Sexual: 0, | ||
Violence: 4 | ||
} | ||
} | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,18 @@ import { | |
buildDocumentGroundingConfig, | ||
constructCompletionPostRequest | ||
} from './orchestration-utils.js'; | ||
import { | ||
type OrchestrationModuleConfig, | ||
type DocumentGroundingServiceConfig, | ||
type StreamOptions, | ||
AzureFilterThreshold | ||
} from './orchestration-types.js'; | ||
import type { | ||
CompletionPostRequest, | ||
FilteringModuleConfig, | ||
ModuleConfigs, | ||
OrchestrationConfig | ||
} from './client/api/schema/index.js'; | ||
import type { | ||
OrchestrationModuleConfig, | ||
DocumentGroundingServiceConfig, | ||
StreamOptions | ||
} from './orchestration-types.js'; | ||
|
||
describe('orchestration utils', () => { | ||
describe('stream util tests', () => { | ||
|
@@ -82,7 +83,10 @@ describe('orchestration utils', () => { | |
const config: OrchestrationModuleConfig = { | ||
...defaultOrchestrationModuleConfig, | ||
filtering: { | ||
output: buildAzureContentFilter({ Hate: 4, SelfHarm: 0 }) | ||
output: buildAzureContentFilter({ | ||
Hate: AzureFilterThreshold.ALLOW_SAFE_LOW_MEDIUM, | ||
SelfHarm: AzureFilterThreshold.ALLOW_SAFE | ||
}) | ||
Comment on lines
+86
to
+89
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. [q] Can we avoid changing these tests and only add new tests (even just type tests) to avoid merge conflicts with #441? I think it is unnecessary to change those types. |
||
} | ||
}; | ||
const filteringConfig = addStreamOptionsToOutputFilteringConfig( | ||
|
@@ -101,7 +105,10 @@ describe('orchestration utils', () => { | |
const config: ModuleConfigs = { | ||
...defaultModuleConfigs, | ||
filtering_module_config: { | ||
output: buildAzureContentFilter({ Hate: 4, SelfHarm: 0 }) | ||
output: buildAzureContentFilter({ | ||
Hate: AzureFilterThreshold.ALLOW_SAFE_LOW_MEDIUM, | ||
SelfHarm: AzureFilterThreshold.ALLOW_SAFE | ||
}) | ||
} | ||
}; | ||
|
||
|
@@ -174,7 +181,10 @@ describe('orchestration utils', () => { | |
|
||
it('constructs filter configuration with only input', async () => { | ||
const filtering: FilteringModuleConfig = { | ||
input: buildAzureContentFilter({ Hate: 4, SelfHarm: 0 }) | ||
input: buildAzureContentFilter({ | ||
Hate: AzureFilterThreshold.ALLOW_SAFE_LOW_MEDIUM, | ||
SelfHarm: AzureFilterThreshold.ALLOW_SAFE | ||
}) | ||
}; | ||
const expectedFilterConfig: FilteringModuleConfig = { | ||
input: { | ||
|
@@ -200,7 +210,10 @@ describe('orchestration utils', () => { | |
|
||
it('constructs filter configuration with only output', async () => { | ||
const filtering: FilteringModuleConfig = { | ||
output: buildAzureContentFilter({ Sexual: 2, Violence: 6 }) | ||
output: buildAzureContentFilter({ | ||
Sexual: AzureFilterThreshold.ALLOW_SAFE_LOW, | ||
Violence: AzureFilterThreshold.ALLOW_ALL | ||
}) | ||
}; | ||
const expectedFilterConfig: FilteringModuleConfig = { | ||
output: { | ||
|
@@ -227,12 +240,15 @@ describe('orchestration utils', () => { | |
it('constructs filter configuration with both input and output', async () => { | ||
const filtering: FilteringModuleConfig = { | ||
input: buildAzureContentFilter({ | ||
Hate: 4, | ||
SelfHarm: 0, | ||
Sexual: 2, | ||
Violence: 6 | ||
Hate: AzureFilterThreshold.ALLOW_SAFE_LOW_MEDIUM, | ||
SelfHarm: AzureFilterThreshold.ALLOW_SAFE, | ||
Sexual: AzureFilterThreshold.ALLOW_SAFE_LOW, | ||
Violence: AzureFilterThreshold.ALLOW_ALL | ||
}), | ||
output: buildAzureContentFilter({ Sexual: 2, Violence: 6 }) | ||
output: buildAzureContentFilter({ | ||
Sexual: AzureFilterThreshold.ALLOW_SAFE_LOW, | ||
Violence: AzureFilterThreshold.ALLOW_ALL | ||
}) | ||
}; | ||
const expectedFilterConfig: FilteringModuleConfig = { | ||
input: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that
AzureContentSafety
defined inorchestration-types
overrides the type generated from the specification.Modifying the type doesn't seem to be a breaking change as in the end they would both resolve to be the same code in JS.