Skip to content

Latest commit

 

History

History
107 lines (73 loc) · 5.37 KB

README.md

File metadata and controls

107 lines (73 loc) · 5.37 KB

Classifiers

(classifiers)

Overview

Classifiers API.

Available Operations

moderate

Moderations

Example Usage

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)

Parameters

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.

Response

models.ClassificationResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

moderate_chat

Moderations Chat

Example Usage

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)

Parameters

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.

Response

models.ClassificationResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*