You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 10, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/python-sdk.md
+69-8Lines changed: 69 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -245,9 +245,9 @@ Here’s the complete list of filter operators that are currently supported
245
245
246
246
These functions let you retrieve information about labeling tasks defined within a project, and start and cancel a task run.
247
247
248
-
### Get Tasks
248
+
### Define a new Task
249
249
250
-
You can retrieve a list of all tasks within a given project as follows
250
+
You can create a new task programmatically within a given project as follows:
251
251
252
252
```python
253
253
import refuel
@@ -259,6 +259,26 @@ options = {
259
259
260
260
refuel_client = refuel.init(**options)
261
261
262
+
refuel_client.create_task(
263
+
task='<TASK NAME>',
264
+
task_type='<TASK TYPE>',
265
+
dataset='<DATASET NAME>',
266
+
input_columns=['col 1', 'col 2'...],
267
+
context='...',
268
+
fields= [{'name': '...', 'guidelines': ...}]
269
+
)
270
+
```
271
+
272
+
- task_type is one of: `classification`, `multilabel_classification` or `attribute_extraction`
273
+
- input_columns is the subset of columns from the dataset that will be used as input for LLM
274
+
- fields is a list of dictionaries. Each dictionary contains a fixed set of keys: name (name of the LLM label field as it will be appear in the exported dataset), guidelines (labeling guidelines for the LLM) and labels (list of valid labels, this field is only required for classification type tasks)
275
+
276
+
### Get Tasks
277
+
278
+
You can retrieve a list of all tasks within a given project as follows
Each element in `inputs` is a dictionary, with keys as names of the input columns defined in the task. For example, let's consider an application for sentiment classification called `my_sentiment_classifier`, with two input fields - `source` and `text`. You can use it as follows:
333
364
334
365
```python
335
366
inputs = [
336
-
{'<COL 1>': '<VALUE FOR COL 1>', '<COL 2>': '<VALUE FOR COL 2>'...}
367
+
{'source': 'yelp.com', 'text': 'I really liked the pizza at this restaurant.'}
Each element in input is a dictionary with keys corresponding to the input columns defined in the task. For example, if the task has two input columns, “name” and “description”, then each entry will be a dictionary with two keys, “name” and “description”. The values for these keys will be the name and description values for that input. E.g.:
373
+
`response`has the following schema:
343
374
344
-
`[{"name": "example name value", "description": "example description value"}]`
375
+
-`refuel_output[i]` contains the output for `inputs[i]`
376
+
-`refuel_fields` is a list whose length is equal to the number of fields defined in the application. For example, let's say `my_sentiment_classifier` has just one field, `sentiment`. In this case the output will be:
377
+
378
+
```
379
+
{
380
+
'application_id': '...',
381
+
'application_name': 'my_sentiment_classifier',
382
+
'refuel_output': [
383
+
{'refuel_uuid': '...',
384
+
'refuel_api_timestamp': '...',
385
+
'refuel_fields':
386
+
{
387
+
'sentiment': {
388
+
'label': 'positive,
389
+
'confidence': 0.9758
390
+
}
391
+
}
392
+
}]
393
+
}
394
+
```
395
+
396
+
397
+
### Share feedback for application outputs
398
+
399
+
The SDK allows users to log feedback for online predictions. When logging predictions, it is important to identify the input request for which you're logging feedback using `refuel_uuid` from the response above:
It is recommended to use smaller batches for inputs (<= 10). For larger datasets, we recommend using batch-mode: uploading a dataset and triggering a labeling run.
407
+
Any row with logged feedback will appear with the verified check mark ("✓") in the cloud application.
0 commit comments