Synchronous Classification Endpoint
This endpoint allows you to classify text based on the labels you have set up synchronously. This endpoint analyzes the input text and returns predictions about which labels apply, including the confidence level for each prediction.
Endpoint Overview
The Classification endpoint is designed to classify text (e.g., emails, messages) into predefined categories (labels). The request can either include subject and metadata fields or just the body of a message. The response provides a list of detected labels, including the prediction confidence and priority.
Endpoint:
POST /api/companies/{companyCuid}/orchestrators/{orchestratorCuid}/classification
Request Parameters
The Classification endpoint accepts the following parameters in the body of the request:
Payload Structure
| Field | Type | Required | Description |
|---|---|---|---|
| subject | String | No | The subject or title of the text (optional). |
| metadata | Object | No | Any additional metadata related to the text (optional). |
| body | String | Yes | The body of the message or the main content of the text to classify. |
Example Request Payload
{
"subject": "Complaint about my order",
"metadata": {
"order_id": "12345",
"customer_id": "67890"
},
"body": "I would like to file a complaint about my recent purchase. The item is damaged."
}
Response Structure
The response from the Classification endpoint will provide predictions, including a main prediction (the most probable label) and a list of predictions with their confidence and priority.
Response Fields
| Field | Type | Description |
|---|---|---|
| main_prediction | String | The most likely label for the input text (e.g., "reclamation"). |
| predictions | Array | An array of objects, each containing a label and its confidence. |
| predictions.label | String | The name of the predicted label. |
| predictions.confidence | String | The confidence level of the prediction (e.g., "high", "medium", "low"). |
| predictions.priority | Integer | A priority score to indicate the relevance of the prediction. |
Example Response Payload
{
"main_prediction": "reclamation",
"predictions": [
{
"label": "reclamation",
"confidence": "high",
"priority": 1
},
{
"label": "product_issue",
"confidence": "medium",
"priority": 2
}
]
}
Best Practices for Using the Classification Endpoint
- Provide Context: If possible, always include the subject and metadata in the request to give the model more context for better predictions.
- Use Clear Labels: Ensure your labels are clearly defined and represent distinct categories to avoid confusion in the predictions.
For additional information on managing labels or examples, refer to the following pages: