From aafe93ff82a070e43c113ee0d1b89863e4f44922 Mon Sep 17 00:00:00 2001 From: Vechtomov Date: Thu, 5 Jan 2023 22:50:51 +0300 Subject: [PATCH] simplified random task generation --- backend/oasst_backend/api/v1/tasks.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/oasst_backend/api/v1/tasks.py b/backend/oasst_backend/api/v1/tasks.py index e9ecc854..82b2f773 100644 --- a/backend/oasst_backend/api/v1/tasks.py +++ b/backend/oasst_backend/api/v1/tasks.py @@ -24,14 +24,14 @@ def generate_task( match request.type: case protocol_schema.TaskRequestType.random: logger.info("Frontend requested a random task.") - while request.type == protocol_schema.TaskRequestType.random: - disabled_tasks = ( - protocol_schema.TaskRequestType.summarize_story, - protocol_schema.TaskRequestType.rate_summary, - ) - request.type = random.choice( - tuple(set(protocol_schema.TaskRequestType).difference(disabled_tasks)) - ).value + disabled_tasks = ( + protocol_schema.TaskRequestType.random, + protocol_schema.TaskRequestType.summarize_story, + protocol_schema.TaskRequestType.rate_summary, + ) + request.type = random.choice( + tuple(set(protocol_schema.TaskRequestType).difference(disabled_tasks)) + ).value return generate_task(request, pr) # AKo: Summary tasks are currently disabled/supported, we focus on the conversation tasks.