Class ModerationsEndpoint
- Namespace
- OpenAI.Moderations
- Assembly
- OpenAI-DotNet.dll
The moderation endpoint is a tool you can use to check whether content complies with OpenAI's content policy.
Developers can thus identify content that our content policy prohibits and take action, for instance by filtering it.
https://platform.openai.com/docs/api-reference/moderations
public sealed class ModerationsEndpoint : OpenAIBaseEndpoint
- Inheritance
-
ModerationsEndpoint
- Inherited Members
Constructors
ModerationsEndpoint(OpenAIClient)
public ModerationsEndpoint(OpenAIClient client)
Parameters
client
OpenAIClient
Properties
Root
The root endpoint address.
protected override string Root { get; }
Property Value
Methods
CreateModerationAsync(ModerationsRequest, CancellationToken)
Classifies if text violates OpenAI's Content Policy
public Task<ModerationsResponse> CreateModerationAsync(ModerationsRequest request, CancellationToken cancellationToken = default)
Parameters
request
ModerationsRequestcancellationToken
CancellationTokenOptional, CancellationToken.
Returns
GetModerationAsync(string, string, CancellationToken)
Classifies if text violates OpenAI's Content Policy.
public Task<bool> GetModerationAsync(string input, string model = null, CancellationToken cancellationToken = default)
Parameters
input
stringThe input text to classify.
model
stringThe default is text-moderation-latest which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use text-moderation-stable, we will provide advanced notice before updating the model. Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.
cancellationToken
CancellationTokenOptional, CancellationToken.
Returns
GetModerationChunkedAsync(string, string, int, int, CancellationToken)
Classifies if text violates OpenAI's Content Policy.
public Task<bool> GetModerationChunkedAsync(string input, string model = null, int chunkSize = 1000, int chunkOverlap = 100, CancellationToken cancellationToken = default)
Parameters
input
stringThe input text to classify.
model
stringThe default is text-moderation-latest which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use text-moderation-stable, we will provide advanced notice before updating the model. Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.
chunkSize
intMaximum size each chunk can be.
chunkOverlap
intHow many characters a chunk should contain from the previous chunk.
cancellationToken
CancellationTokenOptional, CancellationToken.
Returns
Remarks
This version splits input
into chunks and makes multiple moderation requests,
which should provide better results when dealing with a large input
.
On the first flagged chunk, the method returns.