Custom API

We could also support custom API in case you want to use your own model, by telling us the API URL. All you need to do is making sure that the API complies to the request structure.

If you choose Custom, you can simply enter a custom API URL and load in any API of your own choice. You can see a Custom API sample preview by clicking the button beside the text field.

Set up your ML Assisted Custom API

  1. First, create an API for your model with a specific request and response body to use in the Datasaur App. Refer to the API Creation Example for guidance.

  2. Find API request body and response samples next to the API URL dialog or in the examples provided below.

  3. For Row Based

    1. Target text: Pick which text to use as input for reference.

    2. Target question: Decide which output column to predict.

    3. Faster prediction speed: Toggle this option to run predictions faster via the backend.

  4. Fill in the API URL in the Extension.

  5. Click "Predict Labels" to apply labels to your document.

Span Labeling Sample

Request Body
{
    "id": "[project_id]",
    "name": "[project_name]",
    "documents": [
      {
        "id": "[document_id_1]",
        "sentences": [
          {
            "id": 0, // zero-based line number of the document
            "text": "first message",
            "metadata": []
          },
          {
            "id": 1,
            "text": "first message",
            "metadata": []
          },
        ]
      }
    ]
  }
Response Body
{
  "id": "[project_id]",
  "documents": [
    {
      "id": "[document_id_1]",
      "labels": [
        {
          "id": 0,
          "entities": [
            {
              "label": "LOCATION",
              "start_char": 10,
              "end_char": 18,
              "layer": 0
            },
            {
              "label": "PERSON",
              "start_char": 20,
              "end_char": 29,
              "layer": 1
            },
          ]
        },
        {
          "id": 1,
          "entities": []
        }
      ]
    }
  ]
}

Row Labeling Sample

Request Body
[
  { "id": 0, "text": "I feel good." },
  { "id": 1, "text": "I don't like it." }
]
Response Body
[
  { "id": 0, "label": "POSITIVE" },
  { "id": 1, "label": "NEGATIVE" }
]

Last updated