Skip to content

Commit

Permalink
wip: is_name
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Sep 15, 2024
1 parent 0655d59 commit af918d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions horde_sdk/ai_horde_api/ai_horde_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
7 changes: 7 additions & 0 deletions horde_sdk/ai_horde_api/apimodels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions horde_sdk/ai_horde_api/apimodels/workers/_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit af918d6

Please sign in to comment.