OpenAIModerator class

A moderator that uses OpenAI's moderation API to review prompts and plans for safety.

Remarks

This moderation can be configure to review the input from the user, output from the model, or both.

Constructors

OpenAIModerator<TState>(OpenAIModeratorOptions)

Creates a new instance of the OpenAI based moderator.

Properties

options

Methods

reviewInput(TurnContext, TState)

Reviews an incoming utterance for safety violations.

reviewOutput(TurnContext, TState, Plan)

Reviews the SAY commands generated by the planner for safety violations.

Constructor Details

OpenAIModerator<TState>(OpenAIModeratorOptions)

Creates a new instance of the OpenAI based moderator.

new OpenAIModerator(options: OpenAIModeratorOptions)

Parameters

options
OpenAIModeratorOptions

Configuration options for the moderator.

Property Details

options

OpenAIModeratorOptions options

Property Value

Method Details

reviewInput(TurnContext, TState)

Reviews an incoming utterance for safety violations.

function reviewInput(context: TurnContext, state: TState): Promise<undefined | Plan>

Parameters

context

TurnContext

Context for the current turn of conversation.

state

TState

Application state for the current turn of conversation.

Returns

Promise<undefined | Plan>

An undefined value to approve the prompt or a new plan to redirect to if not approved.

reviewOutput(TurnContext, TState, Plan)

Reviews the SAY commands generated by the planner for safety violations.

function reviewOutput(context: TurnContext, state: TState, plan: Plan): Promise<Plan>

Parameters

context

TurnContext

Context for the current turn of conversation.

state

TState

Application state for the current turn of conversation.

plan
Plan

Plan generated by the planner.

Returns

Promise<Plan>

The plan to execute. Either the current plan passed in for review or a new plan.