Buckets:

download
raw
1.15 kB
"""gr.Api() component."""
from __future__ import annotations
from typing import Any
from gradio.components.base import Component
class Api(Component):
"""
A generic component that holds any value. Used for generating APIs with no actual frontend component.
"""
EVENTS = []
def __init__(
self,
value: Any,
_api_info: dict[str, str],
label: str = "API",
):
"""
Parameters:
value: default value.
"""
self._api_info = _api_info
super().__init__(value=value, label=label)
def preprocess(self, payload: Any) -> Any:
return payload
def postprocess(self, value: Any) -> Any:
return value
def api_info(self) -> dict[str, str]: # type: ignore[override]
return self._api_info
def example_payload(self) -> Any:
return self.value if self.value is not None else "..."
def example_value(self) -> Any:
return self.value if self.value is not None else "..."
# def get_block_name(self) -> str:
# return "state" # so that it does not render in the frontend, just like state

Xet Storage Details

Size:
1.15 kB
·
Xet hash:
53a800f00d6317749d9dc65916a370ad4d103168d892e759cb39e3e9aa595bb8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.