toloka.client.collectors.Captcha | Source code
Captcha( self, *, uuid: Optional[UUID] = None, history_size: Optional[int] = None )
Collects captcha statistics for every Toloker.
Captcha provides an advanced protection against robots. It is used with conditions:
- StoredResultsCount — How many times the Toloker entered a captcha.
- SuccessRate — The percentage of solved captchas.
- FailRate — The percentage of unsolved captchas.
The collector can be used with actions:
- RestrictionV2 blocks access to projects or pools.
- ApproveAllAssignments accepts all Toloker's assignments.
- RejectAllAssignments rejects all Toloker's assignments.
- SetSkill sets Toloker's skill value.
- SetSkillFromOutputField sets Toloker's skill value using an output field.
The ID of a collector. Note that when you clone a pool, both pools start using the same collector, because it is not cloned. Usually, it is not an intended behavior. For example, in this case one collector gathers history size from both pools.
The maximum number of recent captchas used to calculate the statistics. If
The example shows how to block Toloker's access to the project for 15 days if they solve 60% of captchas or less. The rule is applied after entering at least 3 captchas.
new_pool = toloka.pool.Pool(....) new_pool.set_captcha_frequency('MEDIUM') new_pool.quality_control.add_action( collector=toloka.collectors.Captcha(history_size=5), conditions=[ toloka.conditions.SuccessRate < 60, toloka.conditions.StoredResultsCount >= 3, ], action=toloka.actions.RestrictionV2( scope=toloka.user_restriction.UserRestriction.PROJECT, duration=15, duration_unit='DAYS', private_comment='Toloker often makes mistakes in captcha', ) )