Skip to content

Example Python REST API Server Implementation for Datasaur ML-Assisted Labeling Custom API.

Notifications You must be signed in to change notification settings

datasaur-ai/ml-assisted-custom-api-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ML-Assisted Custom API Example

Example Python REST API Server Implementation for Datasaur ML-Assisted Labeling Custom API.

Prerequisites

  1. Install Python >= 3.12

  2. Install Poetry ~= 1.8

Getting Started

  1. Install dependencies

    poetry install
  2. Download spacy model

    spacy download en_core_web_sm
  3. Run service

    fastapi run main.py

API Endpoints

POST /row-based

Accept a list of input rows and return a list of sentiment analysis results (Positive, Negative, or Neutral).

Request:

[
  {
    "id": 1,
    "text": "Product A I love this product",
    "columns": ["Product A", "I love this product"],
    "column_names": ["Product Name", "Product Review"]
  }
]

Response:

[
  {
    "id": 1,
    "label": "Positive"
  }
]

POST /span-based

Accepts a project with documents and sentences, and returns entities recognized in the text.

Request:

{
  "id": "project_id",
  "name": "project_name",
  "documents": [
    {
      "id": "document_id",
      "sentences": [
        {
          "id": 0,
          "text": "John works at Abcd Corp."
        }
      ]
    }
  ]
}

Response:

{
  "id": "project_id",
  "documents": [
    {
      "id": "document_id",
      "labels": [
        {
          "id": 0,
          "entities": [
            {
              "label": "PERSON",
              "start_char": 0,
              "end_char": 4,
              "layer": 0
            },
            {
              "label": "ORG",
              "start_char": 14,
              "end_char": 24,
              "layer": 0
            }
          ]
        }
      ]
    }
  ]
}

About

Example Python REST API Server Implementation for Datasaur ML-Assisted Labeling Custom API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages