From aafe93ff82a070e43c113ee0d1b89863e4f44922 Mon Sep 17 00:00:00 2001 From: Vechtomov Date: Thu, 5 Jan 2023 22:50:51 +0300 Subject: [PATCH 1/2] 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. From df0c48c4fa74513c8387f4bbbdfa68a0260e5de6 Mon Sep 17 00:00:00 2001 From: Vechtomov Date: Thu, 5 Jan 2023 22:59:12 +0300 Subject: [PATCH 2/2] clean up --- backend/oasst_backend/api/v1/tasks.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/oasst_backend/api/v1/tasks.py b/backend/oasst_backend/api/v1/tasks.py index 82b2f773..05dc92a9 100644 --- a/backend/oasst_backend/api/v1/tasks.py +++ b/backend/oasst_backend/api/v1/tasks.py @@ -29,9 +29,8 @@ def generate_task( protocol_schema.TaskRequestType.summarize_story, protocol_schema.TaskRequestType.rate_summary, ) - request.type = random.choice( - tuple(set(protocol_schema.TaskRequestType).difference(disabled_tasks)) - ).value + candidate_tasks = set(protocol_schema.TaskRequestType).difference(disabled_tasks) + request.type = random.choice(tuple(candidate_tasks)).value return generate_task(request, pr) # AKo: Summary tasks are currently disabled/supported, we focus on the conversation tasks.