Ƭ AccessToken: string
Actually hf_${string}, but for convenience, using the string type
Ƭ AccessTokenRole: "admin" | "write" | "contributor" | "read"
Ƭ AuthType: "access_token" | "app_token" | "app_token_as_user"
Ƭ CommitOperation: CommitDeletedEntry | CommitFile
Ƭ CommitProgressEvent: { event: "phase" ; phase: "preuploading" | "uploadingLargeFiles" | "committing" } | { event: "fileProgress" ; path: string ; progress: number ; state: "hashing" | "uploading" }
Ƭ ContentSource: Blob | URL
Ƭ Dtype: "F64" | "F32" | "F16" | "BF16" | "I64" | "I32" | "I16" | "I8" | "U8" | "BOOL"
hub/src/lib/parse-safetensors-metadata.ts:21
Ƭ PipelineType: keyof typeof PIPELINE_DATA
tasks/dist/index.d.ts:442
Ƭ RepoDesignation: RepoId | RepoFullName
Ƭ RepoFullName: string | `spaces/${string}` | `datasets/${string}`
Ƭ RepoType: "space" | "dataset" | "model"
Ƭ SafetensorsFileHeader: Record<TensorName, TensorInfo> & { __metadata__: Record<string, string> }
hub/src/lib/parse-safetensors-metadata.ts:29
Ƭ SafetensorsParseFromRepo: { header: SafetensorsFileHeader ; parameterCount?: Partial<Record<Dtype, number>> ; sharded: false } | { headers: SafetensorsShardedHeaders ; index: SafetensorsIndexJson ; parameterCount?: Partial<Record<Dtype, number>> ; sharded: true }
hub/src/lib/parse-safetensors-metadata.ts:43
Ƭ SafetensorsShardedHeaders: Record<FileName, SafetensorsFileHeader>
hub/src/lib/parse-safetensors-metadata.ts:41
Ƭ SpaceEntry: { id: string ; likes: number ; name: string ; private: boolean ; sdk?: SpaceSdk ; updatedAt: Date } & Partial<Omit<ApiSpaceInfo, "updatedAt">>
Ƭ SpaceHardwareFlavor: "cpu-basic" | "cpu-upgrade" | "t4-small" | "t4-medium" | "a10g-small" | "a10g-large" | "a100-large"
Ƭ SpaceSdk: "streamlit" | "gradio" | "docker" | "static"
Ƭ SpaceStage: "NO_APP_FILE" | "CONFIG_ERROR" | "BUILDING" | "BUILD_ERROR" | "RUNNING" | "RUNNING_BUILDING" | "RUNTIME_ERROR" | "DELETING" | "PAUSED" | "SLEEPING"
Ƭ TensorName: string
hub/src/lib/parse-safetensors-metadata.ts:20
Ƭ WhoAmI: WhoAmIApp | WhoAmIOrg | WhoAmIUser
▸ commit(params): Promise<CommitOutput>
| Name | Type |
|---|---|
params | CommitParams |
Promise<CommitOutput>
▸ commitIter(params): AsyncGenerator<CommitProgressEvent, CommitOutput>
Internal function for now, used by commit.
Can be exposed later to offer fine-tuned progress info
| Name | Type |
|---|---|
params | CommitParams |
AsyncGenerator<CommitProgressEvent, CommitOutput>
▸ createRepo(params): Promise<{ repoUrl: string }>
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.credentials | Credentials | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
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” |
Promise<{ repoUrl: string }>
▸ deleteFile(params): Promise<CommitOutput>
| Name | Type |
|---|---|
params | Object |
params.branch? | string |
params.commitDescription? | string |
params.commitTitle? | string |
params.credentials | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
params.isPullRequest? | boolean |
params.parentCommit? | string |
params.path | string |
params.repo | RepoDesignation |
Promise<CommitOutput>
▸ deleteFiles(params): Promise<CommitOutput>
| Name | Type |
|---|---|
params | Object |
params.branch? | string |
params.commitDescription? | string |
params.commitTitle? | string |
params.credentials | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
params.isPullRequest? | boolean |
params.parentCommit? | string |
params.paths | string[] |
params.repo | RepoDesignation |
Promise<CommitOutput>
▸ deleteRepo(params): Promise<void>
| Name | Type |
|---|---|
params | Object |
params.credentials | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
params.repo | RepoDesignation |
Promise<void>
▸ downloadFile(params): Promise<Response | null>
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.credentials? | Credentials | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
params.hubUrl? | string | - |
params.path | string | - |
params.range? | [number, number] | Fetch only a specific part of the file |
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 | - |
Promise<Response | null>
null when the file doesn’t exist
hub/src/lib/download-file.ts:10
▸ fileDownloadInfo(params): Promise<FileDownloadInfoOutput | null>
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.credentials? | Credentials | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
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 | - |
Promise<FileDownloadInfoOutput | null>
null when the file doesn’t exist
hub/src/lib/file-download-info.ts:18
▸ fileExists(params): Promise<boolean>
| Name | Type |
|---|---|
params | Object |
params.credentials? | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
params.path | string |
params.repo | RepoDesignation |
params.revision? | string |
Promise<boolean>
▸ listDatasets(params?): AsyncGenerator<DatasetEntry>
| Name | Type |
|---|---|
params? | Object |
params.credentials? | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
params.search? | Object |
params.search.owner? | string |
AsyncGenerator<DatasetEntry>
hub/src/lib/list-datasets.ts:20
▸ listFiles(params): AsyncGenerator<ListFileEntry>
List files in a folder. To list ALL files in the directory, call it
with params.recursive set to true.
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.credentials? | Credentials | - |
params.expand? | boolean | Fetch lastCommit and securityStatus for each file. |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
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 | - |
AsyncGenerator<ListFileEntry>
▸ listModels(params?): AsyncGenerator<ModelEntry>
| Name | Type |
|---|---|
params? | Object |
params.credentials? | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
params.search? | Object |
params.search.owner? | string |
params.search.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" | "text-to-audio" | "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" | "image-to-video" | "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" | "text-to-video" | "visual-question-answering" | "document-question-answering" | "zero-shot-image-classification" | "graph-ml" | "mask-generation" | "zero-shot-object-detection" | "text-to-3d" | "image-to-3d" | "other" |
AsyncGenerator<ModelEntry>
▸ listSpaces(params?): AsyncGenerator<SpaceEntry>
| Name | Type | Description |
|---|---|---|
params? | Object | - |
params.additionalFields? | keyof ApiSpaceInfo[] | Additional fields to fetch from huggingface.co. |
params.credentials? | Credentials | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
params.hubUrl? | string | - |
params.search? | Object | - |
params.search.owner? | string | - |
AsyncGenerator<SpaceEntry>
▸ parseSafetensorsMetadata(params): Promise<SetRequired<SafetensorsParseFromRepo, "parameterCount">>
Analyze model.safetensors.index.json or model.safetensors from a model hosted on Hugging Face using smart range requests to extract its metadata.
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.computeParametersCount | true | Will include SafetensorsParseFromRepo[“parameterCount”], an object containing the number of parameters for each DType Default false |
params.credentials? | Credentials | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
params.hubUrl? | string | - |
params.repo | RepoDesignation | Only models are supported |
params.revision? | string | - |
Promise<SetRequired<SafetensorsParseFromRepo, "parameterCount">>
hub/src/lib/parse-safetensors-metadata.ts:148
▸ parseSafetensorsMetadata(params): Promise<SafetensorsParseFromRepo>
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.computeParametersCount? | boolean | Will include SafetensorsParseFromRepo[“parameterCount”], an object containing the number of parameters for each DType Default false |
params.credentials? | Credentials | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> | Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. |
params.hubUrl? | string | - |
params.repo | RepoDesignation | Only models are supported |
params.revision? | string | - |
Promise<SafetensorsParseFromRepo>
hub/src/lib/parse-safetensors-metadata.ts:165
▸ uploadFile(params): Promise<CommitOutput>
| Name | Type |
|---|---|
params | Object |
params.abortSignal? | AbortSignal |
params.branch? | string |
params.commitDescription? | string |
params.commitTitle? | string |
params.credentials? | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.file | URL | File | { content: ContentSource ; path: string } |
params.hubUrl? | string |
params.isPullRequest? | boolean |
params.parentCommit? | string |
params.repo | RepoDesignation |
params.useWebWorkers? | boolean | { minSize?: number ; poolSize?: number } |
Promise<CommitOutput>
▸ uploadFiles(params): Promise<CommitOutput>
| Name | Type |
|---|---|
params | Object |
params.abortSignal? | AbortSignal |
params.branch? | string |
params.commitDescription? | string |
params.commitTitle? | string |
params.credentials? | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.files | (URL | File | { content: ContentSource ; path: string })[] |
params.hubUrl? | string |
params.isPullRequest? | boolean |
params.parentCommit? | string |
params.repo | RepoDesignation |
params.useWebWorkers? | boolean | { minSize?: number ; poolSize?: number } |
Promise<CommitOutput>
▸ uploadFilesWithProgress(params): AsyncGenerator<CommitProgressEvent, CommitOutput>
Uploads with progress
Needs XMLHttpRequest to be available for progress events for uploads Set useWebWorkers to true in order to have progress events for hashing
| Name | Type | Description |
|---|---|---|
params | Object | - |
params.abortSignal? | AbortSignal | - |
params.branch? | string | - |
params.commitDescription? | string | - |
params.commitTitle? | string | - |
params.credentials? | Credentials | - |
params.files | (URL | File | { content: ContentSource ; path: string })[] | - |
params.hubUrl? | string | - |
params.isPullRequest? | boolean | - |
params.parentCommit? | string | - |
params.repo | RepoDesignation | - |
params.useWebWorkers? | boolean | { minSize?: number ; poolSize?: number } | Set this to true in order to have progress events for hashing |
AsyncGenerator<CommitProgressEvent, CommitOutput>
hub/src/lib/upload-files-with-progress.ts:19
▸ whoAmI(params): Promise<WhoAmI & { auth: AuthInfo }>
| Name | Type |
|---|---|
params | Object |
params.credentials | Credentials |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> |
params.hubUrl? | string |
Promise<WhoAmI & { auth: AuthInfo }>