Skip to content

Commit b04f711

Browse files
authored
[JS] fix: #802 Update moderator name from OpenAI to Content Safety (#986)
## Linked issues #802 closes: #802 ## Details Provide a list of your changes here. If you are fixing a bug, please provide steps to reproduce the bug. #### Change details > Describe your changes, with screenshots and code snippets as appropriate **code snippets**: **screenshots**: ## Attestation Checklist - [ ] My code follows the style guidelines of this project - I have checked for/fixed spelling, linting, and other errors - I have commented my code for clarity - I have made corresponding changes to the documentation (we use [TypeDoc](https://typedoc.org/) to document our code) - My changes generate no new warnings - I have added tests that validates my changes, and provides sufficient test coverage. I have tested with: - Local testing - E2E testing in Teams - New and existing unit tests pass locally with my changes ### Additional information > Feel free to add other relevant information below
1 parent 79917e3 commit b04f711

File tree

11 files changed

+37
-37
lines changed

11 files changed

+37
-37
lines changed

js/packages/api/teams-ai.api.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4521,12 +4521,12 @@
45214521
},
45224522
{
45234523
"kind": "Class",
4524-
"canonicalReference": "@microsoft/teams-ai!AzureOpenAIModerator:class",
4524+
"canonicalReference": "@microsoft/teams-ai!AzureContentSafetyModerator:class",
45254525
"docComment": "/**\n * An Azure OpenAI moderator that uses OpenAI's moderation API to review prompts and plans for safety.\n *\n * @summary\n *\n * This moderation can be configured to review the input from the user, output from the model, or both. @template TState Optional. Type of the applications turn state.\n */\n",
45264526
"excerptTokens": [
45274527
{
45284528
"kind": "Content",
4529-
"text": "export declare class AzureOpenAIModerator<TState extends "
4529+
"text": "export declare class AzureContentSafetyModerator<TState extends "
45304530
},
45314531
{
45324532
"kind": "Reference",
@@ -4560,7 +4560,7 @@
45604560
"text": " "
45614561
}
45624562
],
4563-
"fileUrlPath": "src/AzureOpenAIModerator.ts",
4563+
"fileUrlPath": "src/AzureContentSafetyModerator.ts",
45644564
"releaseTag": "Public",
45654565
"typeParameters": [
45664566
{
@@ -4576,12 +4576,12 @@
45764576
}
45774577
],
45784578
"isAbstract": false,
4579-
"name": "AzureOpenAIModerator",
4579+
"name": "AzureContentSafetyModerator",
45804580
"preserveMemberOrder": false,
45814581
"members": [
45824582
{
45834583
"kind": "Constructor",
4584-
"canonicalReference": "@microsoft/teams-ai!AzureOpenAIModerator:constructor(1)",
4584+
"canonicalReference": "@microsoft/teams-ai!AzureContentSafetyModerator:constructor(1)",
45854585
"docComment": "/**\n * Creates a new instance of the OpenAI based moderator.\n *\n * @param options - Configuration options for the moderator.\n */\n",
45864586
"excerptTokens": [
45874587
{
@@ -4614,7 +4614,7 @@
46144614
},
46154615
{
46164616
"kind": "Method",
4617-
"canonicalReference": "@microsoft/teams-ai!AzureOpenAIModerator#createClient:member(1)",
4617+
"canonicalReference": "@microsoft/teams-ai!AzureContentSafetyModerator#createClient:member(1)",
46184618
"docComment": "/**\n * Creates a new instance of the Azure OpenAI client.\n *\n * @protected\n *\n * @param options - The options for the moderator.\n */\n",
46194619
"excerptTokens": [
46204620
{
@@ -4664,7 +4664,7 @@
46644664
},
46654665
{
46664666
"kind": "Method",
4667-
"canonicalReference": "@microsoft/teams-ai!AzureOpenAIModerator#createModeration:member(1)",
4667+
"canonicalReference": "@microsoft/teams-ai!AzureContentSafetyModerator#createModeration:member(1)",
46684668
"docComment": "/**\n * @protected\n *\n * @summary\n *\n * This method is called by the moderator to moderate the input. @template TState Optional. Type of the applications turn state.\n *\n * @param input - The input to moderate.\n *\n * @returns The moderation results.\n */\n",
46694669
"excerptTokens": [
46704670
{
@@ -4726,7 +4726,7 @@
47264726
},
47274727
{
47284728
"kind": "Method",
4729-
"canonicalReference": "@microsoft/teams-ai!AzureOpenAIModerator#reviewPlan:member(1)",
4729+
"canonicalReference": "@microsoft/teams-ai!AzureContentSafetyModerator#reviewPlan:member(1)",
47304730
"docComment": "/**\n * Reviews the SAY commands generated by the planner for safety violations.\n *\n * @param context - Context for the current turn of conversation.\n *\n * @param state - Application state for the current turn of conversation.\n *\n * @param plan - Plan generated by the planner.\n *\n * @returns The plan to execute. Either the current plan passed in for review or a new plan.\n */\n",
47314731
"excerptTokens": [
47324732
{
@@ -4822,7 +4822,7 @@
48224822
},
48234823
{
48244824
"kind": "Method",
4825-
"canonicalReference": "@microsoft/teams-ai!AzureOpenAIModerator#reviewPrompt:member(1)",
4825+
"canonicalReference": "@microsoft/teams-ai!AzureContentSafetyModerator#reviewPrompt:member(1)",
48264826
"docComment": "/**\n * Reviews an incoming utterance for safety violations.\n *\n * @param context - Context for the current turn of conversation.\n *\n * @param state - Application state for the current turn of conversation.\n *\n * @param prompt - Generated prompt to be reviewed.\n *\n * @param options - Current options for the AI system.\n *\n * @returns An undefined value to approve the prompt or a new plan to redirect to if not approved.\n */\n",
48274827
"excerptTokens": [
48284828
{
@@ -4963,7 +4963,7 @@
49634963
"text": " "
49644964
}
49654965
],
4966-
"fileUrlPath": "src/AzureOpenAIModerator.ts",
4966+
"fileUrlPath": "src/AzureContentSafetyModerator.ts",
49674967
"releaseTag": "Public",
49684968
"name": "AzureOpenAIModeratorOptions",
49694969
"preserveMemberOrder": false,

js/packages/teams-ai/src/moderators/AzureOpenAIModerator.spec.ts renamed to js/packages/teams-ai/src/moderators/AzureContentSafetyModerator.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { strict as assert } from 'assert';
44
import { restore, stub } from 'sinon';
55
import { TurnContext, CloudAdapter } from 'botbuilder';
66
7-
import { AzureOpenAIModerator } from './AzureOpenAIModerator';
7+
import { AzureContentSafetyModerator } from './AzureContentSafetyModerator';
88
import { TurnStateEntry } from '../TurnState';
99
import { AI } from '../AI';
1010
import {
@@ -15,7 +15,7 @@ import {
1515
OpenAIClientResponse
1616
} from '../internals';
1717
18-
describe('AzureOpenAIModerator', () => {
18+
describe('AzureContentSafetyModerator', () => {
1919
afterEach(() => {
2020
restore();
2121
});
@@ -76,7 +76,7 @@ describe('AzureOpenAIModerator', () => {
7676
}
7777
} as any);
7878
79-
const moderator = new AzureOpenAIModerator({
79+
const moderator = new AzureContentSafetyModerator({
8080
apiKey: 'test',
8181
moderate: 'both',
8282
endpoint: 'https://test'
@@ -116,7 +116,7 @@ describe('AzureOpenAIModerator', () => {
116116
}
117117
} as any);
118118
119-
const moderator = new AzureOpenAIModerator({
119+
const moderator = new AzureContentSafetyModerator({
120120
apiKey: 'test',
121121
moderate: 'both',
122122
endpoint: 'https://test'
@@ -164,7 +164,7 @@ describe('AzureOpenAIModerator', () => {
164164
}
165165
} as any);
166166
167-
const moderator = new AzureOpenAIModerator({
167+
const moderator = new AzureContentSafetyModerator({
168168
apiKey: 'test',
169169
moderate: 'both',
170170
endpoint: 'https://test'
@@ -246,7 +246,7 @@ describe('AzureOpenAIModerator', () => {
246246
}
247247
} as any);
248248
249-
const moderator = new AzureOpenAIModerator({
249+
const moderator = new AzureContentSafetyModerator({
250250
apiKey: 'test',
251251
moderate: 'both',
252252
endpoint: 'https://test'
@@ -288,7 +288,7 @@ describe('AzureOpenAIModerator', () => {
288288
}
289289
} as any);
290290
291-
const moderator = new AzureOpenAIModerator({
291+
const moderator = new AzureContentSafetyModerator({
292292
apiKey: 'test',
293293
moderate: 'both',
294294
endpoint: 'https://test'
@@ -326,7 +326,7 @@ describe('AzureOpenAIModerator', () => {
326326
}
327327
} as any);
328328
329-
const moderator = new AzureOpenAIModerator({
329+
const moderator = new AzureContentSafetyModerator({
330330
apiKey: 'test',
331331
moderate: 'both',
332332
endpoint: 'https://test'
@@ -377,7 +377,7 @@ describe('AzureOpenAIModerator', () => {
377377
}
378378
} as any);
379379
380-
const moderator = new AzureOpenAIModerator({
380+
const moderator = new AzureContentSafetyModerator({
381381
apiKey: 'test',
382382
moderate: 'both',
383383
endpoint: 'https://test'
@@ -457,7 +457,7 @@ describe('AzureOpenAIModerator', () => {
457457
}
458458
} as any);
459459
460-
const moderator = new AzureOpenAIModerator({
460+
const moderator = new AzureContentSafetyModerator({
461461
apiKey: 'test',
462462
moderate: 'both',
463463
endpoint: 'https://test'

js/packages/teams-ai/src/moderators/AzureOpenAIModerator.ts renamed to js/packages/teams-ai/src/moderators/AzureContentSafetyModerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const defaultHarmCategories: AzureOpenAIModeratorCategory[] = ['Hate', 'Sexual',
6262
* This moderation can be configured to review the input from the user, output from the model, or both.
6363
* @template TState Optional. Type of the applications turn state.
6464
*/
65-
export class AzureOpenAIModerator<TState extends TurnState = TurnState> extends OpenAIModerator<TState> {
65+
export class AzureContentSafetyModerator<TState extends TurnState = TurnState> extends OpenAIModerator<TState> {
6666
private readonly _contentSafetyOptions: ContentSafetyOptions;
6767
private readonly _azureContentSafetyClient: AzureOpenAIClient;
6868
private readonly _azureContentSafetyCategories: Record<string, ContentSafetyHarmCategory> = {};

js/packages/teams-ai/src/moderators/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Licensed under the MIT License.
77
*/
88

9-
export * from './AzureOpenAIModerator';
9+
export * from './AzureContentSafetyModerator';
1010
export * from './DefaultModerator';
1111
export * from './Moderator';
1212
export * from './OpenAIModerator';

js/samples/04.ai.a.teamsChefBot/index/teams-ai.links

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/s
1313
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/AI.ts
1414
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/Application.ts
1515
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/AzureOpenAIPlanner.ts
16-
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/AzureOpenAIModerator.ts
16+
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/AzureContentSafetyModerator.ts
1717
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/ConversationHistory.ts
1818
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/DefaultModerator.ts
1919
https://raw.githubusercontent.com/microsoft/teams-ai/main/js/packages/teams-ai/src/DefaultPromptManager.ts

js/samples/04.ai.a.teamsChefBot/index/teams-ai/84d4cd91-90ad-4c76-962e-d220e2607436.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const defaultHarmCategories: AzureOpenAIModeratorCategory[] = ['Hate', 'Sexual',
6262
* This moderation can be configured to review the input from the user, output from the model, or both.
6363
* @template TState Optional. Type of the applications turn state.
6464
*/
65-
export class AzureOpenAIModerator<TState extends TurnState = DefaultTurnState> extends OpenAIModerator<TState> {
65+
export class AzureContentSafetyModerator<TState extends TurnState = DefaultTurnState> extends OpenAIModerator<TState> {
6666
private readonly _contentSafetyOptions: ContentSafetyOptions;
6767
private readonly _azureContentSafetyClient: AzureOpenAIClient;
6868
private readonly _azureContentSafetyCategories: Record<string, ContentSafetyHarmCategory> = {};

0 commit comments

Comments
 (0)