Skip to content

Commit 531904f

Browse files
committed
updated README.md
1 parent 05b254c commit 531904f

File tree

1 file changed

+236
-0
lines changed

1 file changed

+236
-0
lines changed

README.md

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,239 @@ Example:
619619
```python
620620
response = ml.extractors.list(page=2, per_page=5, order_by=['-is_public', 'name'])
621621
```
622+
623+
### Workflows
624+
625+
#### [Workflow detail](https://monkeylearn.com/api/v3/#workflow-detail)
626+
627+
```python
628+
def MonkeyLearn.workflows.detail(model_id, step_id, retry_if_throttled=True)
629+
```
630+
631+
Parameters:
632+
633+
| Parameter |Type | Description |
634+
|--------------------|-------------------|-----------------------------------------------------------|
635+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
636+
|*step_id* |`int` |Step ID. |
637+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
638+
639+
Example:
640+
641+
```python
642+
response = ml.workflows.detail('[MODEL_ID]', '[STEP_ID]')
643+
```
644+
645+
<br>
646+
647+
#### [Create workflow](https://monkeylearn.com/api/v3/#create-workflow)
648+
649+
```python
650+
def MonkeyLearn.workflows.create(name, db_name, steps, description='', webhook_url=None,
651+
custom_fields=None, sources=None, retry_if_throttled=True)
652+
```
653+
654+
Parameters:
655+
656+
Parameter | Type | Description
657+
--------- | ------- | -----------
658+
*name* | `str` | The name of the model.
659+
*db_name* | `str` | The name of the database where the data will be stored. The name must not already be in use by another database.
660+
*steps* | `list[dict]` | A list of step dicts.
661+
*description* | `str` | The description of the model.
662+
*webhook_url* | `str` | An URL that will be called when an action is triggered.
663+
*custom_fields* | `[]`| A list of custom_field dicts that represent user defined fields that come with the input data and that will be saved. It does not include the mandatory `text` field.
664+
*sources* | `{}` | An object that represents the data sources of the workflow.
665+
666+
Example:
667+
668+
```python
669+
response = ml.workflows.create(
670+
name='Example Workflow',
671+
db_name='example_workflow',
672+
steps=[{
673+
name: 'sentiment',
674+
model_id: 'cl_pi3C7JiL'
675+
}, {
676+
name: 'keywords',
677+
model_id: 'ex_YCya9nrn'
678+
}])
679+
```
680+
681+
<br>
682+
683+
#### [Delete workflow](https://monkeylearn.com/api/v3/#delete-workflow)
684+
685+
```python
686+
def MonkeyLearn.workflows.delete(model_id, retry_if_throttled=True)
687+
```
688+
689+
Parameters:
690+
691+
| Parameter |Type | Description |
692+
|--------------------|-------------------|-----------------------------------------------------------|
693+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
694+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
695+
696+
Example:
697+
698+
```python
699+
response = ml.workflows.delete('[MODEL_ID]')
700+
```
701+
702+
<br>
703+
704+
#### [Step detail](https://monkeylearn.com/api/v3/#step-detail)
705+
706+
```python
707+
def MonkeyLearn.workflows.steps.detail(model_id, step_id, retry_if_throttled=True)
708+
```
709+
710+
Parameters:
711+
712+
| Parameter |Type | Description |
713+
|--------------------|-------------------|-----------------------------------------------------------|
714+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
715+
|*step_id* |`int` |Step ID. |
716+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
717+
718+
Example:
719+
720+
``` python
721+
response = ml.workflows.steps.detail('[MODEL_ID]', STEP_ID)
722+
```
723+
724+
<br>
725+
726+
#### [Create step](https://monkeylearn.com/api/v3/#create-step)
727+
728+
```python
729+
def MonkeyLearn.workflows.steps.create(model_id, name, step_model_id, input=None,
730+
conditions=None, retry_if_throttled=True)
731+
```
732+
733+
Parameters:
734+
735+
| Parameter |Type | Description |
736+
|--------------------|-------------------|-----------------------------------------------------------|
737+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
738+
|*name* |`str` |The name of the new step. |
739+
|*step_model_id* |`str` |The ID of the MonkeyLearn model that will run in this step. Must be an existing classifier or extractor. |
740+
|*input* |`str` |Where the input text to use in this step comes from. It can be either the name of a step or `input_data` (the default), which means that the input will be the original text. |
741+
|*conditions* |`list[dict]` |A list of condition dicts that indicate whether this step should execute or not. All the conditions in the list must be true for the step to execute. |
742+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
743+
744+
Example:
745+
746+
```python
747+
response = ml.workflows.steps.create(model_id='[MODEL_ID]', name='sentiment',
748+
step_model_id='cl_pi3C7JiL')
749+
```
750+
751+
<br>
752+
753+
#### [Delete step](https://monkeylearn.com/api/v3/#delete-step)
754+
755+
```python
756+
def MonkeyLearn.workflows.steps.delete(model_id, step_id, retry_if_throttled=True)
757+
```
758+
759+
Parameters:
760+
761+
| Parameter |Type | Description |
762+
|--------------------|-------------------|-----------------------------------------------------------|
763+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
764+
|*step_id* |`int` |Step ID. |
765+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
766+
767+
Example:
768+
769+
```python
770+
response = ml.workflows.steps.delete('[MODEL_ID]', STEP_ID)
771+
```
772+
773+
<br>
774+
775+
#### [Upload workflow data](https://monkeylearn.com/api/v3/#upload-workflow-data)
776+
777+
```python
778+
def MonkeyLearn.workflows.data.create(model_id, data, retry_if_throttled=True)
779+
```
780+
781+
Parameters:
782+
783+
| Parameter |Type | Description |
784+
|--------------------|-------------------|-----------------------------------------------------------|
785+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
786+
|*data* |`list[dict]` |A list of dicts with the keys described below.
787+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
788+
789+
`data` dict keys:
790+
791+
|Key | Description |
792+
|--------- | ----------- |
793+
|text | A *string* of the text to upload.|
794+
|[custom field name] | The value for a custom field for this text. The type of the value must be the one specified when the field was created.|
795+
796+
797+
Example:
798+
799+
```python
800+
response = ml.workflows.data.create(
801+
model_id='[MODEL_ID]',
802+
data=[{'text': 'text 1', 'rating': 3},
803+
{'text': 'text 2', 'rating': 4}]
804+
)
805+
```
806+
807+
<br>
808+
809+
#### [List workflow data](https://monkeylearn.com/api/v3/#list-workflow-data)
810+
811+
```python
812+
def MonkeyLearn.workflows.data.list(model_id, batch_id=None, is_processed=None,
813+
sent_to_process_date_from=None, sent_to_process_date_to=None,
814+
page=None, per_page=None, retry_if_throttled=True)
815+
```
816+
817+
Parameters:
818+
819+
Parameter | Type | Description
820+
--------- | ------- | -----------
821+
page | `int` | The page number to be retrieved.
822+
per_page | `int` | The maximum number of items the page should have. The maximum allowed value is `50`.
823+
batch_id | `int` | The ID of the batch to retrieve. If unspecified, data from all batches is shown.
824+
is_processed | `bool` | Whether to return data that has been processed or data that has not been processed yet. If unspecified, both are shown indistinctly.
825+
sent_to_process_date_from | `str` | An [ISO formatted date](https://en.wikipedia.org/wiki/ISO_8601) which specifies the oldest `sent_date` of the data to be retrieved.
826+
sent_to_process_date_to | `str` | An [ISO formatted date](https://en.wikipedia.org/wiki/ISO_8601) which specifies the most recent `sent_date` of the data to be retrieved.
827+
828+
Example:
829+
830+
```python
831+
response = ml.workflows.data.list('[MODEL_ID]', batch_id=1839, page=1)
832+
```
833+
834+
<br>
835+
836+
#### [Create custom field](https://monkeylearn.com/api/v3/#create-custom-field)
837+
838+
839+
```python
840+
def MonkeyLearn.workflows.custom_fields.create(model_id, name, data_type, retry_if_throttled=True)
841+
```
842+
843+
Parameters:
844+
845+
| Parameter |Type | Description |
846+
|--------------------|-------------------|-----------------------------------------------------------|
847+
|*model_id* |`str` |Workflow ID. It always starts with `'wf'`, for example, `'wf_oJNMkt2V'`. |
848+
|*name* |`str` |The name of the new custom field. |
849+
|*data_type* |`str` |The type of the data of the field. It must be one of `string`, `date`, `text`, `integer`, `float`, `bool`. |
850+
|*retry_if_throttled* |`bool` |If a request is [throttled](https://monkeylearn.com/api/v3/#query-limits), sleep and retry the request. |
851+
852+
Example:
853+
854+
```python
855+
response = ml.workflows.custom_fields.create(model_id='[MODEL_ID]', name='rating',
856+
data_type='integer')
857+
```

0 commit comments

Comments
 (0)