View Source ExOpenAI.Moderations (ex_openai.ex v1.7.0)
Modules for interacting with the moderations
group of OpenAI APIs
API Reference: https://platform.openai.com/docs/api-reference/moderations
Summary
Functions
Classifies if text is potentially harmful.
Functions
@spec create_moderation([String.t()] | String.t(), base_url: String.t(), openai_organization_key: String.t(), openai_api_key: String.t(), model: (:"text-moderation-stable" | :"text-moderation-latest") | String.t(), stream_to: (... -> any()) | pid() ) :: {:ok, ExOpenAI.Components.CreateModerationResponse.t()} | {:error, any()}
Classifies if text is potentially harmful.
Endpoint: https://api.openai.com/v1/moderations
Method: POST
Docs: https://platform.openai.com/docs/api-reference/moderations
Required Arguments:
input
: The input text to classify
Optional Arguments:
stream_to
: PID or function of where to stream content tomodel
: Two content moderations models are available:text-moderation-stable
andtext-moderation-latest
.
The 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
.
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.base_url
: Which API endpoint to use as base, defaults to https://api.openai.com/v1