Scale is an API for human labor. With the Scale API, you can deploy real humans, on-demand, to execute tasks like content moderation, phone surveys, transcription, e-commerce tagging, and image recognition. The API handles everything from sourcing and managing the crowd to building efficient tooling.
With the Scale API block, execute these tasks while the data is streaming in real time. The function is executed while the data is in-motion, not when it is received by the subscriber.
Check out our Getting Started with Scale API tutorial, and we'll show you how to get Scale API to categorize images in real time.
This block uses the asynchronous Scale API to process data which has been received on the input channel. After Scale is finished processing the data, it will publish a response object to dynamic output channel. Every channel which subscribed on the output channel will receive the processed data.
To make it possible for the block to send a response to a remote user which has requested it, input/output channel names should follow certain pattern: sa-task-create.uuid (for input channel to which request will be sent) and sa-uuid.taskid (for output channel). uuid should be replaced with real remote user identifier which requested data processing. taskid is same value which has been sent with request under sab_id
key (allow to link task with local models if required).
To enable dynamic channel names, creation wildcard subscription should be enabled for keys on which block will be launched.
Published object should follow specification defined in Scale API. The object should also include two fields: sab_id
and sab_type
. sab_type
is one of the available task types: categorize, transcription, phonecall, comparison or annotation.
It's required to provide scaleAPIKey to access Scale API. Also it is possible to specify whether processed data should be stored in dynamic channel's history by changing value for storeTasksUpdatesInHistory
.
The audition block allows the retrieval of information on previously processed requests, but to make it work, additional parameters should be changed: storeTaskIdentifiers
. Audition on completed tasks can be done only using same uuid value which has been used during processing request.
Publish message on input channel: sa-task-create.uuid
Replace uuid with value which is used during submitting PubNub client configuration.
{ "sab_id": "1", "sab_type": "categorize", "instruction": "Is this company public or private?", "attachment_type": "website", "attachment": "http://www.google.com/", "categories": [ "public", "private" ] }
Client subscribe on output channel: sa-uuid.*
Replace uuid with value which is used during submitting PubNub client configuration.
{ "task": { "completed_at": "2016-11-21T20:25:39.230Z", "response": { "category": "public" }, "created_at": "2016-11-21T20:25:39.225Z", "callback_url": "https://pubsub.pubnub.com/publish/pub-9c4a1e5c-33bf-497b-bae7-9e643b8710cc/sub-c673492b-3e47-11e2-adf4-77ab52641c9b/0/sa-moonlight.undefined/0?store=1&uuid=scale-api-block", "type": "categorization", "status": "completed", "instruction": "Is this company public or private?", "urgency": "day", "params": { "allow_multiple": false, "categories": [ "public", "private" ], "attachment": "http://www.google.com/", "attachment_type": "website" }, "is_test": true, "task_id": "58335843f2a61f0600018c84", "metadata": {} }, "response": { "category": "public" }, "task_id": "58335843f2a61f0600018c84" }
Need help? Contact PubNub Support.
Copyright (c) 2018 PubNub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.