(classifiers)
Classifiers API.
- moderate - Moderations
- moderate_chat - Moderations Chat
Moderations
from mistralai import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.classifiers.moderate(inputs=[
"<value>",
])
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
inputs |
models.ClassificationRequestInputs | ✔️ | Text to classify. |
model |
OptionalNullable[str] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Moderations Chat
from mistralai import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.classifiers.moderate_chat(inputs=[
[
{
"content": [
{
"text": "<value>",
},
],
},
],
], model="V90")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
inputs |
models.ChatClassificationRequestInputs | ✔️ | Chat to classify |
model |
Nullable[str] | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |