(classifiers)
Classifiers API.
Moderations
from mistralai import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.classifiers.moderate(model="V90", inputs=[
"<value>",
])
# Handle response
print(res)
models.ModerationResponse
Error Type |
Status Code |
Content Type |
models.HTTPValidationError |
422 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
Chat Moderations
from mistralai import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.classifiers.moderate_chat(inputs=[
[
{
"content": [
],
"role": "system",
},
{
"content": "<value>",
"role": "tool",
},
],
[
{
"prefix": False,
"role": "assistant",
},
{
"content": "<value>",
"role": "user",
},
{
"prefix": False,
"role": "assistant",
},
],
[
{
"content": "<value>",
"role": "system",
},
{
"content": [
{
"image_url": "https://fatherly-colon.name",
"type": "image_url",
},
],
"role": "user",
},
{
"content": "<value>",
"role": "user",
},
],
], model="Model Y")
# Handle response
print(res)
models.ModerationResponse
Error Type |
Status Code |
Content Type |
models.HTTPValidationError |
422 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
Classifications
from mistralai import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.classifiers.classify(model="Altima", inputs="<value>")
# Handle response
print(res)
models.ClassificationResponse
Error Type |
Status Code |
Content Type |
models.HTTPValidationError |
422 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
Chat Classifications
from mistralai import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.classifiers.classify_chat(model="Fortwo", inputs=[
{
"messages": [
{
"content": "<value>",
"role": "tool",
},
],
},
{
"messages": [
],
},
])
# Handle response
print(res)
models.ClassificationResponse
Error Type |
Status Code |
Content Type |
models.HTTPValidationError |
422 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |