Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 83 additions & 10 deletions .mock/definition/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,79 @@ service:
response:
docs: ''
type: root.LseTask
examples:
- name: Create Task
request:
data:
image: https://example.com/image.jpg
text: Hello, world!
project: 1
response:
body:
agreement: agreement
agreement_selected: agreement_selected
annotations: annotations
annotations_ids: annotations_ids
annotations_results: annotations_results
annotators:
- 1
annotators_count: 1
avg_lead_time: 1.1
cancelled_annotations: 1
comment_authors:
- key: value
comment_authors_count: 1
comment_count: 1
comments: comments
completed_at: '2024-01-15T09:30:00Z'
created_at: '2024-01-15T09:30:00Z'
data:
key: value
draft_exists: true
drafts:
- created_at: '2024-01-15T09:30:00Z'
result:
- key: value
updated_at: '2024-01-15T09:30:00Z'
file_upload: file_upload
ground_truth: true
id: 1
inner_id: 1
is_labeled: true
last_comment_updated_at: '2024-01-15T09:30:00Z'
meta:
key: value
overlap: 1
predictions:
- created_at: '2024-01-15T09:30:00Z'
model:
key: value
model_run:
key: value
model_version: model_version
project: 1
result:
- key: value
score: 1.1
task: 1
updated_at: '2024-01-15T09:30:00Z'
predictions_model_versions: predictions_model_versions
predictions_results: predictions_results
predictions_score: 1.1
project: 1
reviewed: true
reviewers:
- key: value
reviewers_count: 1
reviews_accepted: 1
reviews_rejected: 1
storage_filename: storage_filename
total_annotations: 1
total_predictions: 1
unresolved_comment_count: 1
updated_at: '2024-01-15T09:30:00Z'
updated_by:
- key: value
audiences:
- public
get:
Expand Down Expand Up @@ -556,41 +629,41 @@ service:
docs: |2-

Create a new task event to track user interactions and system events during annotation.

This endpoint is designed to receive events from the frontend labeling interface to enable
accurate lead time calculation and detailed annotation analytics.

## Event Types

**Core Annotation Events:**
- `annotation_loaded` - When annotation interface is loaded
- `annotation_submitted` - When annotation is submitted
- `annotation_updated` - When annotation is modified
- `annotation_reviewed` - When annotation is reviewed

**User Activity Events:**
- `visibility_change` - When page visibility changes (tab switch, minimize)
- `idle_detected` - When user goes idle
- `idle_resumed` - When user returns from idle

**Interaction Events:**
- `region_finished_drawing` - When annotation region is completed
- `region_deleted` - When annotation regions are removed
- `hotkey_pressed` - When keyboard shortcuts are used

**Media Events:**
- `video_playback_start/end` - Video playback control
- `audio_playback_start/end` - Audio playback control
- `video_scrub` - Video timeline scrubbing

## Usage

Events are automatically associated with the task specified in the URL path.
The current user is automatically set as the actor. Project and organization
are derived from the task context.

## Example Request

```json
{
"event_key": "annotation_loaded",
Expand Down
11 changes: 10 additions & 1 deletion .mock/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15714,6 +15714,15 @@ paths:
requestBody:
content:
application/json:
examples:
CreateTask:
description: Example of Create Task
summary: Create Task
value:
data:
image: https://example.com/image.jpg
text: Hello, world!
project: 1
schema:
$ref: '#/components/schemas/LseTaskRequest'
application/x-www-form-urlencoded:
Expand Down Expand Up @@ -16013,7 +16022,7 @@ paths:
x-fern-sdk-method-name: create
/api/tasks/{id}/events/:
post:
description: "\n Create a new task event to track user interactions and system events during annotation.\n \n This endpoint is designed to receive events from the frontend labeling interface to enable\n accurate lead time calculation and detailed annotation analytics.\n \n ## Event Types\n \n **Core Annotation Events:**\n - `annotation_loaded` - When annotation interface is loaded\n - `annotation_submitted` - When annotation is submitted\n - `annotation_updated` - When annotation is modified\n - `annotation_reviewed` - When annotation is reviewed\n \n **User Activity Events:**\n - `visibility_change` - When page visibility changes (tab switch, minimize)\n - `idle_detected` - When user goes idle\n - `idle_resumed` - When user returns from idle\n \n **Interaction Events:**\n - `region_finished_drawing` - When annotation region is completed\n - `region_deleted` - When annotation regions are removed\n - `hotkey_pressed` - When keyboard shortcuts are used\n \n **Media Events:**\n - `video_playback_start/end` - Video playback control\n - `audio_playback_start/end` - Audio playback control\n - `video_scrub` - Video timeline scrubbing\n \n ## Usage\n \n Events are automatically associated with the task specified in the URL path.\n The current user is automatically set as the actor. Project and organization\n are derived from the task context.\n \n ## Example Request\n \n ```json\n {\n \"event_key\": \"annotation_loaded\",\n \"event_time\": \"2024-01-15T10:30:00Z\",\n \"annotation\": 123,\n \"meta\": {\n \"annotation_count\": 5,\n \"estimated_time\": 300\n }\n }\n ```\n "
description: "\n Create a new task event to track user interactions and system events during annotation.\n\n This endpoint is designed to receive events from the frontend labeling interface to enable\n accurate lead time calculation and detailed annotation analytics.\n\n ## Event Types\n\n **Core Annotation Events:**\n - `annotation_loaded` - When annotation interface is loaded\n - `annotation_submitted` - When annotation is submitted\n - `annotation_updated` - When annotation is modified\n - `annotation_reviewed` - When annotation is reviewed\n\n **User Activity Events:**\n - `visibility_change` - When page visibility changes (tab switch, minimize)\n - `idle_detected` - When user goes idle\n - `idle_resumed` - When user returns from idle\n\n **Interaction Events:**\n - `region_finished_drawing` - When annotation region is completed\n - `region_deleted` - When annotation regions are removed\n - `hotkey_pressed` - When keyboard shortcuts are used\n\n **Media Events:**\n - `video_playback_start/end` - Video playback control\n - `audio_playback_start/end` - Audio playback control\n - `video_scrub` - Video timeline scrubbing\n\n ## Usage\n\n Events are automatically associated with the task specified in the URL path.\n The current user is automatically set as the actor. Project and organization\n are derived from the task context.\n\n ## Example Request\n\n ```json\n {\n \"event_key\": \"annotation_loaded\",\n \"event_time\": \"2024-01-15T10:30:00Z\",\n \"annotation\": 123,\n \"meta\": {\n \"annotation_count\": 5,\n \"estimated_time\": 300\n }\n }\n ```\n "
operationId: api_tasks_events_create
parameters:
- description: Task ID to associate the event with
Expand Down
23 changes: 12 additions & 11 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -10207,7 +10207,8 @@ client = LabelStudio(
api_key="YOUR_API_KEY",
)
client.tasks.create(
data={"key": "value"},
data={"image": "https://example.com/image.jpg", "text": "Hello, world!"},
project=1,
)

```
Expand Down Expand Up @@ -10740,41 +10741,41 @@ client.tasks.update(


Create a new task event to track user interactions and system events during annotation.

This endpoint is designed to receive events from the frontend labeling interface to enable
accurate lead time calculation and detailed annotation analytics.

## Event Types

**Core Annotation Events:**
- `annotation_loaded` - When annotation interface is loaded
- `annotation_submitted` - When annotation is submitted
- `annotation_updated` - When annotation is modified
- `annotation_reviewed` - When annotation is reviewed

**User Activity Events:**
- `visibility_change` - When page visibility changes (tab switch, minimize)
- `idle_detected` - When user goes idle
- `idle_resumed` - When user returns from idle

**Interaction Events:**
- `region_finished_drawing` - When annotation region is completed
- `region_deleted` - When annotation regions are removed
- `hotkey_pressed` - When keyboard shortcuts are used

**Media Events:**
- `video_playback_start/end` - Video playback control
- `audio_playback_start/end` - Audio playback control
- `video_scrub` - Video timeline scrubbing

## Usage

Events are automatically associated with the task specified in the URL path.
The current user is automatically set as the actor. Project and organization
are derived from the task context.

## Example Request

```json
{
"event_key": "annotation_loaded",
Expand Down
9 changes: 7 additions & 2 deletions src/label_studio_sdk/tasks/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ def create(
api_key="YOUR_API_KEY",
)
client.tasks.create(
data={"key": "value"},
data={"image": "https://example.com/image.jpg", "text": "Hello, world!"},
project=1,
)
"""
_response = self._client_wrapper.httpx_client.request(
Expand Down Expand Up @@ -1203,7 +1204,11 @@ async def create(

async def main() -> None:
await client.tasks.create(
data={"key": "value"},
data={
"image": "https://example.com/image.jpg",
"text": "Hello, world!",
},
project=1,
)


Expand Down
Loading
Loading