@huggingface/hub

Classes

Interfaces

Type Aliases

AccessToken

Ƭ AccessToken: string

Actually hf_${string}, but for convenience, using the string type

Defined in

hub/src/types/public.d.ts:13


AccessTokenRole

Ƭ AccessTokenRole: "admin" | "write" | "contributor" | "read"

Defined in

hub/src/types/public.d.ts:42


AuthType

Ƭ AuthType: "access_token" | "app_token" | "app_token_as_user"

Defined in

hub/src/types/public.d.ts:44


CommitOperation

Ƭ CommitOperation: CommitDeletedEntry | CommitFile

Defined in

hub/src/lib/commit.ts:52


ContentSource

Ƭ ContentSource: Blob | URL

Defined in

hub/src/lib/commit.ts:33


RepoDesignation

Ƭ RepoDesignation: RepoId | RepoFullName

Defined in

hub/src/types/public.d.ts:10


RepoFullName

Ƭ RepoFullName: string | `spaces/${string}` | `datasets/${string}`

Defined in

hub/src/types/public.d.ts:8


RepoType

Ƭ RepoType: "space" | "dataset" | "model"

Defined in

hub/src/types/public.d.ts:1


SpaceHardwareFlavor

Ƭ SpaceHardwareFlavor: "cpu-basic" | "cpu-upgrade" | "t4-small" | "t4-medium" | "a10g-small" | "a10g-large" | "a100-large"

Defined in

hub/src/types/public.d.ts:19


SpaceSdk

Ƭ SpaceSdk: "streamlit" | "gradio" | "docker" | "static"

Defined in

hub/src/types/public.d.ts:28


SpaceStage

Ƭ SpaceStage: "NO_APP_FILE" | "CONFIG_ERROR" | "BUILDING" | "BUILD_ERROR" | "RUNNING" | "RUNNING_BUILDING" | "RUNTIME_ERROR" | "DELETING" | "PAUSED" | "SLEEPING"

Defined in

hub/src/types/public.d.ts:30


Task

Ƭ Task: "text-classification" | "token-classification" | "table-question-answering" | "question-answering" | "zero-shot-classification" | "translation" | "summarization" | "conversational" | "feature-extraction" | "text-generation" | "text2text-generation" | "fill-mask" | "sentence-similarity" | "text-to-speech" | "automatic-speech-recognition" | "audio-to-audio" | "audio-classification" | "voice-activity-detection" | "depth-estimation" | "image-classification" | "object-detection" | "image-segmentation" | "text-to-image" | "image-to-text" | "image-to-image" | "unconditional-image-generation" | "video-classification" | "reinforcement-learning" | "robotics" | "tabular-classification" | "tabular-regression" | "tabular-to-text" | "table-to-text" | "multiple-choice" | "text-retrieval" | "time-series-forecasting" | "visual-question-answering" | "document-question-answering" | "zero-shot-image-classification" | "graph-ml" | "other"

Defined in

hub/src/types/public.d.ts:46


WhoAmI

Ƭ WhoAmI: WhoAmIApp | WhoAmIOrg | WhoAmIUser

Defined in

hub/src/lib/who-am-i.ts:58

Functions

commit

commit(params): Promise<CommitOutput>

Parameters

Name Type
params CommitParams

Returns

Promise<CommitOutput>

Defined in

hub/src/lib/commit.ts:420


createRepo

createRepo(params): Promise<{ repoUrl: string }>

Parameters

Name Type Description
params Object -
params.credentials Credentials -
params.files? { content: ArrayBuffer | Blob ; path: string }[] Only a few lightweight files are supported at repo creation
params.hubUrl? string -
params.license? string -
params.private? boolean -
params.repo RepoDesignation -
params.sdk? SpaceSdk Required for when repo.type === “space”

Returns

Promise<{ repoUrl: string }>

Defined in

hub/src/lib/create-repo.ts:9


deleteRepo

deleteRepo(params): Promise<void>

Parameters

Name Type
params Object
params.credentials Credentials
params.hubUrl? string
params.repo RepoDesignation

Returns

Promise<void>

Defined in

hub/src/lib/delete-repo.ts:7


downloadFile

downloadFile(params): Promise<Response | null>

Parameters

Name Type Description
params Object -
params.credentials? Credentials -
params.hubUrl? string -
params.path string -
params.raw? boolean If true, will download the raw git file. For example, when calling on a file stored with Git LFS, the pointer file will be downloaded instead.
params.repo RepoDesignation -
params.revision? string -

Returns

Promise<Response | null>

null when the file doesn’t exist

Defined in

hub/src/lib/download-file.ts:10


fileDownloadInfo

fileDownloadInfo(params): Promise<FileDownloadInfoOutput | null>

Parameters

Name Type Description
params Object -
params.credentials? Credentials -
params.hubUrl? string -
params.noContentDisposition? boolean To avoid the content-disposition header in the downloadLink for LFS files So that on browsers you can use the URL in an iframe for example
params.path string -
params.raw? boolean To get the raw pointer file behind a LFS file
params.repo RepoDesignation -
params.revision? string -

Returns

Promise<FileDownloadInfoOutput | null>

null when the file doesn’t exist

Defined in

hub/src/lib/file-download-info.ts:18


listDatasets

listDatasets(params?): AsyncGenerator<DatasetEntry>

Parameters

Name Type
params? Object
params.credentials? Credentials
params.hubUrl? string
params.search? Object
params.search.owner? string

Returns

AsyncGenerator<DatasetEntry>

Defined in

hub/src/lib/list-datasets.ts:20


listFiles

listFiles(params): AsyncGenerator<ListFileEntry>

List files in a folder. To list ALL files in the directory, call it with params.recursive set to true.

Parameters

Name Type Description
params Object -
params.credentials? Credentials -
params.hubUrl? string -
params.path? string Eg ‘data’ for listing all files in the ‘data’ folder. Leave it empty to list all files in the repo.
params.recursive? boolean Do we want to list files in subdirectories?
params.repo RepoDesignation -
params.revision? string -

Returns

AsyncGenerator<ListFileEntry>

Defined in

hub/src/lib/list-files.ts:32


listModels

listModels(params?): AsyncGenerator<ModelEntry>

Parameters

Name Type
params? Object
params.credentials? Credentials
params.hubUrl? string
params.search? Object
params.search.owner? string
params.search.task? Task

Returns

AsyncGenerator<ModelEntry>

Defined in

hub/src/lib/list-models.ts:21


listSpaces

listSpaces(params?): AsyncGenerator<SpaceEntry>

Parameters

Name Type
params? Object
params.credentials? Credentials
params.hubUrl? string
params.search? Object
params.search.owner? string

Returns

AsyncGenerator<SpaceEntry>

Defined in

hub/src/lib/list-spaces.ts:19


whoAmI

whoAmI(params): Promise<WhoAmI & { auth: AuthInfo }>

Parameters

Name Type
params Object
params.credentials Credentials
params.hubUrl? string

Returns

Promise<WhoAmI & { auth: AuthInfo }>

Defined in

hub/src/lib/who-am-i.ts:68