This commit is contained in:
2026-04-12 01:02:14 +08:00
parent 509487f155
commit 9b053e302b
14085 changed files with 2680009 additions and 12 deletions

View File

@@ -0,0 +1,68 @@
from typing import TYPE_CHECKING, Any, Dict, List
from typing_extensions import deprecated
from replicate.resource import Namespace, Resource
if TYPE_CHECKING:
pass
class Hardware(Resource):
"""
Hardware for running a model on Replicate.
"""
sku: str
"""
The SKU of the hardware.
"""
name: str
"""
The name of the hardware.
"""
@property
@deprecated("Use `sku` instead of `id`")
def id(self) -> str:
"""
DEPRECATED: Use `sku` instead.
"""
return self.sku
class HardwareNamespace(Namespace):
"""
Namespace for operations related to hardware.
"""
def list(self) -> List[Hardware]:
"""
List all hardware available for you to run models on Replicate.
Returns:
List[Hardware]: A list of hardware.
"""
resp = self._client._request("GET", "/v1/hardware")
obj = resp.json()
return [_json_to_hardware(entry) for entry in obj]
async def async_list(self) -> List[Hardware]:
"""
List all hardware available for you to run models on Replicate.
Returns:
List[Hardware]: A list of hardware.
"""
resp = await self._client._async_request("GET", "/v1/hardware")
obj = resp.json()
return [_json_to_hardware(entry) for entry in obj]
def _json_to_hardware(json: Dict[str, Any]) -> Hardware:
return Hardware(**json)