mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-17 11:13:32 +08:00
770 tree manager allow to specify desired task_type no prompter ranking (#775)
* only ranking assistant replies by default * add tasks/availability endpoint allow to specify desired task * move rank_prompter_replies option to TreeManagerConfiguration * fix type annotation * remove desired_task_type from _random_task_selection() * fix typo * Convert query_tree_size to sqlachemy, return 'full' text-labeling tasks if they were explicitly requested
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
@@ -48,6 +48,27 @@ def request_task(
|
||||
return task
|
||||
|
||||
|
||||
@router.post("/availability", response_model=dict[protocol_schema.TaskRequestType, int])
|
||||
def tasks_availability(
|
||||
*,
|
||||
user: Optional[protocol_schema.User] = None,
|
||||
db: Session = Depends(deps.get_db),
|
||||
api_key: APIKey = Depends(deps.get_api_key),
|
||||
):
|
||||
api_client = deps.api_auth(api_key, db)
|
||||
|
||||
try:
|
||||
pr = PromptRepository(db, api_client, client_user=user)
|
||||
tm = TreeManager(db, pr)
|
||||
return tm.determine_task_availability()
|
||||
|
||||
except OasstError:
|
||||
raise
|
||||
except Exception:
|
||||
logger.exception("Task availability query failed.")
|
||||
raise OasstError("Task availability query failed.", OasstErrorCode.TASK_AVAILABILITY_QUERY_FAILED)
|
||||
|
||||
|
||||
@router.post("/{task_id}/ack", response_model=None, status_code=HTTP_204_NO_CONTENT)
|
||||
def tasks_acknowledge(
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user