removed addressed user

This commit is contained in:
Yannic Kilcher
2022-12-16 18:08:58 +01:00
parent ae03dd08c7
commit 385d2733ab
3 changed files with 4 additions and 20 deletions
+3 -14
View File
@@ -120,8 +120,6 @@ def generate_task(request: protocol_schema.TaskRequest) -> protocol_schema.Task:
)
logger.info(f"Generated {task=}.")
if request.user is not None:
task.addressed_user = request.user
return task
@@ -228,10 +226,7 @@ def post_interaction(
# ToDo: role user or agent?
pr.store_text_reply(interaction, role="unknown")
return protocol_schema.TaskDone(
reply_to_post_id=interaction.user_post_id,
addressed_user=interaction.user,
)
return protocol_schema.TaskDone()
case protocol_schema.PostRating:
logger.info(
f"Frontend reports rating of {interaction.post_id=} with {interaction.rating=} by {interaction.user=}."
@@ -240,20 +235,14 @@ def post_interaction(
# here we store the rating in the database
pr.store_rating(interaction)
return protocol_schema.TaskDone(
reply_to_post_id=interaction.post_id,
addressed_user=interaction.user,
)
return protocol_schema.TaskDone()
case protocol_schema.PostRanking:
logger.info(
f"Frontend reports ranking of {interaction.post_id=} with {interaction.ranking=} by {interaction.user=}."
)
# TODO: check if the ranking is valid
# here we would store the ranking in the database
return protocol_schema.TaskDone(
reply_to_post_id=interaction.post_id,
addressed_user=interaction.user,
)
return protocol_schema.TaskDone()
case _:
raise HTTPException(
status_code=HTTP_400_BAD_REQUEST,
-2
View File
@@ -62,7 +62,6 @@ class Task(BaseModel):
id: UUID = pydantic.Field(default_factory=uuid4)
type: str
addressed_user: Optional[User] = None
class SummarizeStoryTask(Task):
@@ -151,7 +150,6 @@ class TaskDone(Task):
"""Signals to the frontend that the task is done."""
type: Literal["task_done"] = "task_done"
reply_to_post_id: str
AnyTask = Union[
+1 -4
View File
@@ -205,10 +205,7 @@ def main(backend_url: str, api_key: str):
tasks.append(new_task)
case "task_done":
if addressed_user := task["addressed_user"]:
typer.echo(f"Hey, {addressed_user['display_name']}! Thank you!")
else:
typer.echo("Task done!")
typer.echo("Task done!")
case _:
typer.echo(f"Unknown task type {task['type']}")