Skip to content

Toxicity Classifier API Doc

Parsa Hejabi edited this page May 17, 2022 · 6 revisions

/v1/toxicity/ - POST Request

JSON Request Body -

{
    "thread": [
        {
            "postId": "p03",
            "userId": "toxguy01",
            "title": "some hateful title",
            "text": "some really hateful text",
            "comments": [
                {
                    "userId": "abc123",
                    "content": "hey you jerk, quit talking",
                    "commentId": "t5093",
                    "timestamp": "2022-03-15 09:58:56.563128",
                    "request-label": false,
                    "comments": []
                },
                {
                    "userId": "xyz456",
                    "content": "quit arguing and listen to me you idiot",
                    "commentId": "t5094",
                    "timestamp": "2022-03-15 10:01:56.563900",
                    "request-label": false,
                    "comments": []
                },
                {
                    "userId": "abc123",
                    "content": "I'll listen when you do",
                    "commentId": "t5095",
                    "timestamp": "2022-03-15 10:02:03.347947",
                    "request-label": true,
                    "comments": []
                }
            ]
        },
        {
            "postId": "p04",
            "userId": "toxguy01",
            "title": "some hateful title",
            "text": "some really hateful text",
            "comments": [
                {
                    "userId": "abc123",
                    "content": "I'll listen when you do",
                    "commentId": "t5095",
                    "timestamp": "2022-03-15 10:02:03.347947",
                    "request-label": true,
                    "comments": []
                }
            ]
        }
    ]
}

JSON Response (with a 200 status code) -

{
    "thread": [
        {
            "comments": [
                {
                    "behaviours": [
                        {
                            "score": 0.05,
                            "type": "TOXICITY"
                        },
                        {
                            "score": 0.06,
                            "type": "OBSCENE"
                        },
                        {
                            "score": 0.03,
                            "type": "INSULT"
                        },
                        {
                            "score": 0.02,
                            "type": "IDENTITY_ATTACK"
                        }
                    ],
                    "commentId": "t5095",
                    "userId": "abc123"
                }
            ],
            "postId": "p03",
            "userId": "toxguy01"
        },
        {
            "comments": [
                {
                    "behaviours": [
                        {
                            "score": 0.05,
                            "type": "TOXICITY"
                        },
                        {
                            "score": 0.06,
                            "type": "OBSCENE"
                        },
                        {
                            "score": 0.03,
                            "type": "INSULT"
                        },
                        {
                            "score": 0.02,
                            "type": "IDENTITY_ATTACK"
                        }
                    ],
                    "commentId": "t5095",
                    "userId": "abc123"
                }
            ],
            "postId": "p04",
            "userId": "toxguy01"
        }
    ]
}

Note: Scores are binary classifier probabilities of the behavior type.

/v1/toxicity/types - GET Request

(Development only) Gives the mapping for the behavior types that the classifier is currently tracking and classifying.

Sample JSON response:

{
    "1": "TOXICITY",
    "2": "OBSCENE",
    "3": "INSULT",
    "4": "IDENTITY_ATTACK"
}

Clone this wiki locally