From 7f730594883eed723386ea246f81a0ab1db1e060 Mon Sep 17 00:00:00 2001 From: Yannic Kilcher Date: Fri, 16 Dec 2022 14:59:42 +0100 Subject: [PATCH] added ranking sending to frontend --- text-frontend/__main__.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/text-frontend/__main__.py b/text-frontend/__main__.py index 9ac1dcea..21228909 100644 --- a/text-frontend/__main__.py +++ b/text-frontend/__main__.py @@ -148,7 +148,20 @@ def main(backend_url: str, api_key: str): # acknowledge task _post(f"/api/v1/tasks/{task['id']}/ack", {"post_id": POST_ID}) - typer.prompt("Enter the prompt numbers in order of preference, separated by commas") + ranking_str = typer.prompt("Enter the prompt numbers in order of preference, separated by commas") + ranking = [int(x) for x in ranking_str.split(",")] + + # send ranking + new_task = _post( + "/api/v1/tasks/interaction", + { + "type": "post_ranking", + "post_id": POST_ID, + "ranking": ranking, + "user": USER, + }, + ) + tasks.append(new_task) case "rank_user_replies" | "rank_assistant_replies": typer.echo("Here is the conversation so far:") @@ -160,7 +173,20 @@ def main(backend_url: str, api_key: str): # acknowledge task _post(f"/api/v1/tasks/{task['id']}/ack", {"post_id": POST_ID}) - typer.prompt("Enter the reply numbers in order of preference, separated by commas") + ranking_str = typer.prompt("Enter the reply numbers in order of preference, separated by commas") + ranking = [int(x) for x in ranking_str.split(",")] + + # send ranking + new_task = _post( + "/api/v1/tasks/interaction", + { + "type": "post_ranking", + "post_id": POST_ID, + "ranking": ranking, + "user": USER, + }, + ) + tasks.append(new_task) case "task_done": if addressed_user := task["addressed_user"]: