Skip to content

Latest commit

 

History

History
122 lines (90 loc) · 5.76 KB

README.md

File metadata and controls

122 lines (90 loc) · 5.76 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>",
    ])

    # 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": "<value>",
                "role": "tool",
            },
            {
                "content": "<value>",
                "role": "tool",
            },
            {
                "content": "<value>",
                "role": "tool",
            },
        ],
        [
            {
                "prefix": False,
                "role": "assistant",
            },
            {
                "content": "<value>",
                "role": "user",
            },
            {
                "prefix": False,
                "role": "assistant",
            },
        ],
    ], model="Roadster")

    # 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 */*