Saltar al contenido principal

HuggingFaceCredential

Credential
DashAI.back.credentials.HuggingFaceCredential

Credential for the HuggingFace Hub.

Methods

apply(self) -> None

Defined on HuggingFaceCredential

Log in to the HuggingFace Hub if a key is stored.

verify(self, key: str) -> bool

Defined on HuggingFaceCredential

Validate a HuggingFace token via whoami.

Parameters

key : str
HuggingFace access token.

Returns

bool
True if the token is valid.

auth(self, key: str) -> bool

Defined on BaseCredential

Validate and persist a key.

Parameters

key : str
The key to authenticate with.

Returns

bool
True on success.

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_key(self) -> Optional[str]

Defined on BaseCredential

Return the stored decrypted key, or None.

Returns

Union[str, None]
The decrypted key, or None if not authenticated.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

is_authenticated(self) -> bool

Defined on BaseCredential

Return whether a verified key is stored.

Returns

bool
True if authenticated.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.