Example Python REST API Server Implementation for Datasaur ML-Assisted Labeling Custom API.
-
Install Python >= 3.12
-
Install Poetry ~= 1.8
-
Install dependencies
poetry install
-
Download spacy model
spacy download en_core_web_sm
-
Run service
fastapi run main.py
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"
}
]
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
}
]
}
]
}
]
}