From af918d6f2afac50d32e8e1adf9843a84411dfc12 Mon Sep 17 00:00:00 2001 From: db0 Date: Sun, 15 Sep 2024 15:03:12 +0200 Subject: [PATCH] wip: is_name --- horde_sdk/ai_horde_api/ai_horde_clients.py | 6 ++++-- horde_sdk/ai_horde_api/apimodels/base.py | 7 +++++++ horde_sdk/ai_horde_api/apimodels/workers/_workers.py | 9 +++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/horde_sdk/ai_horde_api/ai_horde_clients.py b/horde_sdk/ai_horde_api/ai_horde_clients.py index a9d0060..b389e55 100644 --- a/horde_sdk/ai_horde_api/ai_horde_clients.py +++ b/horde_sdk/ai_horde_api/ai_horde_clients.py @@ -978,18 +978,20 @@ def workers_all_details( def worker_details( self, worker_id: WorkerID | str, + is_name: bool | None = None, ) -> SingleWorkerDetailsResponse: """Get the details for a worker. Args: - worker_id (WorkerID): The ID of the worker to get the details for. + worker_id (WorkerID or Worker name): The ID of the worker to get the details for. + is_name (bool): if the worker_id argument is the worker name, this needs to be set to true. Returns: SingleWorkerDetailsResponse: The response from the API. """ with AIHordeAPIClientSession() as horde_session: response = horde_session.submit_request( - SingleWorkerDetailsRequest(worker_id=worker_id), + SingleWorkerDetailsRequest(worker_id=worker_id, is_name=is_name), SingleWorkerDetailsResponse, ) diff --git a/horde_sdk/ai_horde_api/apimodels/base.py b/horde_sdk/ai_horde_api/apimodels/base.py index 6995c28..14e018d 100644 --- a/horde_sdk/ai_horde_api/apimodels/base.py +++ b/horde_sdk/ai_horde_api/apimodels/base.py @@ -85,6 +85,13 @@ class WorkerRequestMixin(HordeAPIDataObject): """The UUID of the worker in question for this request.""" +class WorkerGetRequestMixin(HordeAPIDataObject): + """Mix-in class for data relating to worker GET requests.""" + + is_name: bool | None = Field(default=None) + """Whether the worker_id sent is be a worker name instead""" + + class LorasPayloadEntry(HordeAPIDataObject): """Represents a single lora parameter. diff --git a/horde_sdk/ai_horde_api/apimodels/workers/_workers.py b/horde_sdk/ai_horde_api/apimodels/workers/_workers.py index 4009257..6522e15 100644 --- a/horde_sdk/ai_horde_api/apimodels/workers/_workers.py +++ b/horde_sdk/ai_horde_api/apimodels/workers/_workers.py @@ -3,7 +3,7 @@ from pydantic import AliasChoices, Field, RootModel from typing_extensions import override -from horde_sdk.ai_horde_api.apimodels.base import BaseAIHordeRequest, WorkerRequestMixin +from horde_sdk.ai_horde_api.apimodels.base import BaseAIHordeRequest, WorkerGetRequestMixin, WorkerRequestMixin from horde_sdk.ai_horde_api.consts import WORKER_TYPE from horde_sdk.ai_horde_api.endpoints import AI_HORDE_API_ENDPOINT_SUBPATH from horde_sdk.ai_horde_api.fields import TeamID, WorkerID @@ -239,7 +239,12 @@ def get_api_model_name(cls) -> str | None: return "WorkerDetails" -class SingleWorkerDetailsRequest(BaseAIHordeRequest, WorkerRequestMixin, APIKeyAllowedInRequestMixin): +class SingleWorkerDetailsRequest( + BaseAIHordeRequest, + WorkerRequestMixin, + WorkerGetRequestMixin, + APIKeyAllowedInRequestMixin, +): """Returns information on a single worker. If a moderator API key is specified, additional information is returned.