Huggingface.js documentation
@huggingface/hub
@huggingface/hub
클래스
- HubApiError
- InvalidApiResponseFormatError
- JsonStreamParseError
- SafetensorParseError
- __internal_XetBlob
인터페이스
- AuthInfo
- CachedFileInfo
- CachedRepoInfo
- CachedRevisionInfo
- 커밋 파일 복사
- CommitData
- CommitDeletedEntry
- 커밋 파일 편집
- CommitEditFileParams
- CommitFile
- CommitInfo
- CommitOutput
- CopyDestination
- CopyFilesEntry
- CopyProgressEvent
- CopySource
- 자격 증명
- DatasetEntry
- FileDownloadInfoOutput
- HFCacheInfo
- JobVolume
- LfsPathInfo
- ListFileEntry
- MlxQuantizationConfig
- ModelConfig
- ModelDerivedFields
- ModelEntry
- OAuthResult
- ParallelDownloadOptions
- PathInfo
- QuantizationConfig
- RangeEditCacheEntry
- RepoId
- SafetensorsIndexJson
- SafetensorsShardFileInfo
- SecurityFileStatus
- SpaceEntry
- SpaceResourceConfig
- SpaceResourceRequirement
- SpaceRuntime
- TensorInfo
- UserInfo
- WhoAmIApp
- WhoAmIOrg
- WhoAmIUser
- XetFileInfo
- XetReadToken
타입 별칭
AccessToken
Ƭ AccessToken: string
실제로는 hf_${string}이지만, 편의상 string 타입을 사용합니다
정의 위치
packages/hub/src/types/public.ts:28
AccessTokenRole
Ƭ AccessTokenRole: "admin" | "write" | "contributor" | "read"
정의 위치
packages/hub/src/types/public.ts:98
AuthType
Ƭ AuthType: "access_token" | "app_token" | "app_token_as_user"
정의 위치
packages/hub/src/types/public.ts:100
CommitOperation
Ƭ CommitOperation: CommitDeletedEntry | CommitFile | CommitEditFile | CommitCopyFile
정의 위치
packages/hub/src/lib/commit.ts:123
CommitParams
Ƭ CommitParams: { abortSignal?: AbortSignal ; branch?: string ; description?: string ; fetch?: typeof __type ; hubUrl?: string ; isPullRequest?: boolean ; maxFolderDepth?: number ; operations: CommitOperation[] ; parentCommit?: string ; rangeEditCache?: RangeEditCache ; repo: RepoDesignation ; title: string ; useWebWorkers?: boolean | { minSize?: number ; poolSize?: number } ; useXet?: boolean } & Partial<CredentialsParams>
정의 위치
packages/hub/src/lib/commit.ts:130
CommitProgressEvent
Ƭ CommitProgressEvent: { event: "phase" ; phase: "preuploading" | "uploadingLargeFiles" | "committing" } | { event: "fileProgress" ; path: string ; progress: number ; state: "hashing" | "uploading" | "error" }
정의 위치
packages/hub/src/lib/commit.ts:200
ContentSource
Ƭ ContentSource: Blob | URL
정의 위치
packages/hub/src/lib/commit.ts:44
Dtype
Ƭ 데이터 유형: "F64" | "F32" | "C64" | "F16" | "F8_E4M3" | "F8_E4M3FNUZ" | "F8_E5M2" | "F8_E5M2FNUZ" | "F8_E8M0" | "E8M0" | "F6_E3M2" | "F6_E2M3" | "F4" | "FP4" | "BF16" | "I64" | "U64" | "I32" | "U32" | "I16" | "I8" | "U16" | "U8" | "UE8" | "BOOL"
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:291
JsonStreamEvent
Ƭ JsonStreamEvent: { type: "startObject" } | { type: "endObject" } | { type: "startArray" } | { type: "endArray" } | { key: string ; type: "key" } | { type: "value" ; value: string | number | boolean | null }
최소 구성, 의존성 없음, 증분(SAX 스타일) JSON 파서.
JSON.parse는 전체 문서를 메모리에 두 번(소스 문자열 + 결과 객체 트리) 로드해야 하므로, 문서 자체는 크지만 관심 있는 내용은 매우 작은 경우(예: 큰 MoE의 model.safetensors.index.json에서 60 MB weight_map이 약 100개의 고유 샤드 파일명만 알려주기 위해 존재하는 경우) 사용할 수 없습니다.
이 파서는 바이트가 도착할 때마다 평탄한 이벤트 스트림을 출력하므로, 소비자는 관심 있는 항목만 유지하고 나머지는 가비지 컬렉션에 맡길 수 있습니다. 메모리 사용량은 문서의 크기가 아니라 가장 큰 개별 토큰(문자열/숫자)의 크기로 제한됩니다.
구현은 재개 가능한 상태 머신입니다: 어떤 토큰이든 청크 경계에 걸쳐 나뉠 수 있으며(멀티바이트 UTF-8 시퀀스와 \uXXXX 이스케이프 포함).
Strictness: 허용되는 문법은 RFC 8259(JSON.parse와 동일)이며, 여기서 이점이 적으면서 비용이 많이 드는 몇 가지 검사, 특히 숫자 형식은 상태 머신 대신 Number()로 검증되므로 JSON.parse가 거부하는 일부 입력이 허용됩니다.
JSON.parse가 허용하는 모든 것은 동일한 값으로 허용됩니다.
Example
for await (const event of streamJson(blob.stream())) {
if (event.type === "key") { ... }
}정의 위치
packages/hub/src/utils/streamJson.ts:27
ModelAdditionalField
Ƭ ModelAdditionalField: Exclude<typeof MODEL_EXPANDABLE_KEYS[number], typeof MODEL_EXPAND_KEYS[number]> | keyof ModelDerivedFields
정의 위치
packages/hub/src/lib/list-models.ts:50
PipelineType
Ƭ PipelineType: typeof PIPELINE_DATA의 keyof
정의 위치
packages/tasks/dist/commonjs/pipelines.d.ts:380
RangeEditCache
Ƭ RangeEditCache: Map<string, RangeEditCacheEntry>
이전에 range-edit 경로를 통해 작성된 파일의 인메모리 상태이며, xet 해시로 키가 지정됩니다. 이후의 append(또는 파일의 마지막 term 편집)가 재구성 및 file-chunk-hashes API 호출을 완전히 건너뛰도록 합니다. 부분적인 merkle 상태와 검증 해시가 이미 알려져 있기 때문입니다.
같은 파일에 추가하는 연속된 commit 호출에 동일한 RangeEditCache 인스턴스를 전달하여, 모든 추가 작업마다 CAS 메타데이터 API를 호출하지 않도록 하세요.
정의 위치
packages/hub/src/utils/rangeEdit.ts:16
RepoDesignation
Ƭ RepoDesignation: RepoId | RepoFullName
정의 위치
packages/hub/src/types/public.ts:17
RepoFullName
Ƭ RepoFullName: string | `spaces/${string}` | `datasets/${string}` | `buckets/${string}` | `kernels/${string}`
정의 위치
packages/hub/src/types/public.ts:10
RepoType
Ƭ RepoType: "space" | "dataset" | "model" | "bucket" | "kernel"
정의 위치
packages/hub/src/types/public.ts:3
ResolveModelAdditionalFields
Ƭ ResolveModelAdditionalFields<T>: Pick<ApiModelInfo, T & keyof ApiModelInfo> & Pick<ModelDerivedFields, T & keyof ModelDerivedFields>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | extends ModelAdditionalField |
정의 위치
packages/hub/src/lib/list-models.ts:54
SafetensorsFileHeader
Ƭ SafetensorsFileHeader: Record<TensorName, TensorInfo> & { __metadata__?: { total_parameters?: string | number } & Record<string, string> }
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:324
SafetensorsParseFromRepo
Ƭ SafetensorsParseFromRepo: { filepaths: string[] ; header: SafetensorsFileHeader ; parameterCount?: Partial<Record<Dtype, number>> ; parameterTotal?: number ; sharded: false } | { filepaths: string[] ; headers: SafetensorsShardedHeaders ; index: SafetensorsIndexJson ; parameterCount?: Partial<Record<Dtype, number>> ; parameterTotal?: number ; sharded: true }
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:348
SafetensorsShardedHeaders
Ƭ SafetensorsShardedHeaders: Record<FileName, SafetensorsFileHeader>
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:346
SpaceHardwareFlavor
Ƭ SpaceHardwareFlavor: "cpu-basic" | "cpu-upgrade" | "cpu-performance" | "cpu-xl" | "sprx8" | "zero-a10g" | "inf2x6" | "t4-small" | "t4-medium" | "l4x1" | "l4x4" | "l40sx1" | "l40sx4" | "l40sx8" | "a10g-small" | "a10g-large" | "a10g-largex2" | "a10g-largex4" | "a100-large" | "a100x4" | "a100x8" | "h200" | "h200x2" | "h200x4" | "h200x8" | "rtx-pro-6000" | "rtx-pro-6000x2" | "rtx-pro-6000x4" | "rtx-pro-6000x8"
정의 위치
packages/hub/src/types/public.ts:53
SpaceSdk
Ƭ SpaceSdk: "streamlit" | "gradio" | "docker" | "static"
정의 위치
packages/hub/src/types/public.ts:84
SpaceStage
Ƭ SpaceStage: "NO_APP_FILE" | "CONFIG_ERROR" | "BUILDING" | "BUILD_ERROR" | "RUNNING" | "RUNNING_BUILDING" | "RUNTIME_ERROR" | "DELETING" | "PAUSED" | "SLEEPING"
정의 위치
packages/hub/src/types/public.ts:86
TensorName
Ƭ TensorName: string
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:290
WhoAmI
Ƭ WhoAmI: WhoAmIApp | WhoAmIOrg | WhoAmIUser
정의 위치
packages/hub/src/lib/who-am-i.ts:51
변수
DATASET _ EXPANDABLE _ KEYS
• Const DATASET_EXPANDABLE_KEYS: 읽기 전용 ["author", "cardData", "citation", "createdAt", "disabled", "description", "downloads", "downloadsAllTime", "gated", "gitalyUid", "lastModified", "likes", "paperswithcode_id", "private", "sha", "tags"]
정의 위치
packages/hub/src/lib/list-datasets.ts:17
DATASET _ EXPAND _ KEYS
• Const DATASET_EXPAND_KEYS: 읽기 전용 ["private", "downloads", "gated", "likes", "lastModified"]
정의 위치
packages/hub/src/lib/list-datasets.ts:9
기본 _ 리비전
• Const DEFAULT_REVISION: "main"
정의 위치
packages/hub/src/lib/snapshot-download.ts:13
DIFFUSERS _ SAFETENSORS _ 파일
• Const DIFFUSERS_SAFETENSORS_FILE: "diffusion_pytorch_model.safetensors"
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:21
DIFFUSERS _ SAFETENSORS _ INDEX _ FILE
• Const DIFFUSERS_SAFETENSORS_INDEX_FILE: "diffusion_pytorch_model.safetensors.index.json"
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:22
DIFFUSERS _ WEIGHTS _ SUBFOLDERS
• Const DIFFUSERS_WEIGHTS_SUBFOLDERS: 읽기 전용 ["transformer", "unet"]
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:23
HUB _ URL
• Const HUB_URL: "https://huggingface.co"
Hugging Face Hub의 기본 URL입니다.
정의 위치
모델에서 파생된 필드를 API 키로
• Const MODEL_DERIVED_FIELD_TO_API_KEY: Record<keyof ModelDerivedFields, keyof ApiModelInfo>
정의 위치
packages/hub/src/lib/list-models.ts:46
MODEL _ EXPANDABLE _ KEYS
• Const MODEL_EXPANDABLE_KEYS: 읽기 전용 ["author", "cardData", "config", "createdAt", "disabled", "downloads", "downloadsAllTime", "gated", "gitalyUid", "inferenceProviderMapping", "lastModified", "library_name", "likes", "model-index", "pipeline_tag", "private", "safetensors", "sha", "spaces", "tags", "transformersInfo"]
정의 위치
packages/hub/src/lib/list-models.ts:18
MODEL _ EXPAND _ KEYS
• Const MODEL_EXPAND_KEYS: 읽기 전용 ["pipeline_tag", "private", "gated", "downloads", "likes", "lastModified"]
정의 위치
packages/hub/src/lib/list-models.ts:9
REGEX _ COMMIT _ HASH
• Const REGEX_COMMIT_HASH: RegExp
정의 위치
packages/hub/src/lib/download-file-to-cache-dir.ts:16
REPO _ ID _ SEPARATOR
• Const REPO_ID_SEPARATOR: string = "--"
정의 위치
packages/hub/src/lib/cache-management.ts:25
RE _ SAFETENSORS _ FILE
• Const RE_SAFETENSORS_FILE: RegExp
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:26
RE _ SAFETENSORS _ INDEX _ FILE
• Const RE_SAFETENSORS_INDEX_FILE: RegExp
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:27
RE _ SAFETENSORS _ SHARD _ FILE
• Const RE_SAFETENSORS_SHARD_FILE: RegExp
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:28
SAFETENSORS _ 파일
• Const SAFETENSORS_FILE: "model.safetensors"
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:17
SAFETENSORS _ INDEX _ 파일
• Const SAFETENSORS_INDEX_FILE: "model.safetensors.index.json"
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:18
SPACE _ EXPANDABLE _ KEYS
• Const SPACE_EXPANDABLE_KEYS: 읽기 전용 ["author", "cardData", "datasets", "disabled", "gitalyUid", "lastModified", "createdAt", "likes", "private", "runtime", "sdk", "sha", "subdomain", "tags", "models"]
정의 위치
packages/hub/src/lib/list-spaces.ts:15
SPACE _ EXPAND _ KEYS
• Const SPACE_EXPAND_KEYS: 읽기 전용 ["sdk", "likes", "private", "lastModified"]
정의 위치
packages/hub/src/lib/list-spaces.ts:9
함수
_ _ internal _ sha256
▸ __internal_sha256(buffer, opts?): AsyncGenerator<number, string>
매개변수
| 이름 | 유형 |
|---|---|
buffer | Blob |
opts? | Object |
opts.abortSignal? | AbortSignal |
opts.useWebWorker? | boolean | { minSize?: number ; poolSize?: number } |
반환
AsyncGenerator<number, string>
hex 인코딩된 sha
Yields
진행률 (0-1)
정의 위치
packages/hub/src/utils/sha256.ts:72
assertSafeShardFilename
▸ assertSafeShardFilename(filename): void
weight_map 파일 이름은 저장소 파일에서 가져오므로 공격자가 제어할 수 있습니다. 따라서 인덱스 자체의 디렉터리 내 상대 경로로 유지되어야 합니다.
문자열 includes("..") 검사만으로는 충분하지 않습니다. 파일명이 포함된 URL은 검사 이후에 WHATWG URL 파서에서 파싱되며, 해당 파서는 도트 세그먼트를 퍼센트 디코딩하기 때문입니다. %2e%2e(또는 .%2e, %2E%2E, …)는 이 파서에게 .. 세그먼트로 인식되므로 저장소를 벗어날 수 있으며, 자격 증명이 첨부된 경우 다른 저장소의 resolve URL에 인증된 상태로 요청이 도달하게 됩니다.
%252e%252e와 같은 문제를 포착하기 위해) 검증 전에 반복적으로 디코딩하고, 단순한 상대 경로가 아닌 모든 것을 거부하세요.
매개변수
| 이름 | 유형 |
|---|---|
filename | string |
반환
void
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:511
cancelJob
▸ cancelJob(params): Promise<ApiJob>
작업을 취소합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiJob>
정의 위치
packages/hub/src/lib/jobs/cancel-job.ts:10
checkRepoAccess
▸ checkRepoAccess(params): Promise<void>
리포지토리에 대한 읽기 접근 권한이 있는지 확인합니다.
액세스 권한이 없는 경우 HubApiError 오류를 발생시킵니다. HubApiError.statusCode는 401, 403 또는 404입니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; repo: RepoDesignation } & Partial<CredentialsParams> |
반환
Promise<void>
정의 위치
packages/hub/src/lib/check-repo-access.ts:13
commit
▸ commit(params): Promise<CommitOutput | undefined>
매개변수
| 이름 | 유형 |
|---|---|
params | CommitParams |
반환
Promise<CommitOutput | undefined>
undefined for bucket uploads, CommitOutput otherwise
정의 위치
packages/hub/src/lib/commit.ts:1031
commitIter
▸ commitIter(params): AsyncGenerator<CommitProgressEvent, CommitOutput | undefined>
현재 commit에서 사용되는 내부 함수입니다.
나중에 노출하여 세부 조정된 진행 정보를 제공할 수 있습니다
CommitOutput은 버킷 커밋에 존재하지 않습니다
매개변수
| 이름 | 유형 |
|---|---|
params | CommitParams |
반환
AsyncGenerator<CommitProgressEvent, CommitOutput | undefined>
정의 위치
packages/hub/src/lib/commit.ts:219
commitIterBucket
▸ commitIterBucket(params): AsyncGenerator<CommitProgressEvent>
매개변수
| 이름 | 유형 |
|---|---|
params | CommitParams |
반환
AsyncGenerator<CommitProgressEvent>
정의 위치
packages/hub/src/lib/commit.ts:775
computeNumOfParamsByDtypeSingleFile
▸ computeNumOfParamsByDtypeSingleFile(header, quantConfig?, expertDtype?): Partial<Record<Dtype, number>>
dtype별 매개변수를 하나의 파일 헤더에 대해 합산하며, 양자화 패킹 계수를 적용하고 부기 장부 텐서를 건너뜁니다.
매개변수
| 이름 | 유형 |
|---|---|
header | SafetensorsFileHeader |
quantConfig? | QuantizationConfig |
expertDtype? | string |
반환
Partial<Record<Dtype, number>>
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:1379
copyFile
▸ copyFile(params): Promise<undefined>
소스 저장소/버킷에서 대상 버킷으로 단일 파일을 복사합니다.
소스 파일이 xet 기반인 경우 복사는 서버 측에서 수행되며(데이터 전송 없음),
작은 비-xet 저장소 파일(예: config.json)의 경우 해당 파일이 다운로드된 후
같은 커밋에서 대상 버킷에 다시 업로드됩니다.
xet으로 마이그레이션되지 않은 LFS 포인터 파일은 사전에 거부됩니다(그렇지 않으면 전체 LFS 블롭을 다운로드해야 합니다).
매개변수
| 이름 | 유형 |
|---|---|
params | { destination: CopyDestination ; source: CopySource } & SharedParams |
반환
Promise<undefined>
Example
await copyFile({
source: {
repo: { type: "model", name: "username/my-model" },
path: "model.safetensors",
},
destination: {
repo: { type: "bucket", name: "username/my-bucket" },
path: "models/my-model/model.safetensors",
},
accessToken: "hf_...",
});정의 위치
packages/hub/src/lib/copy-files.ts:111
copyFileIter
▸ copyFileIter(params): AsyncGenerator<CopyProgressEvent, undefined>
비 xet 소스 파일을 다운로드하는 동안 CopyProgressEvent를 yield하는 copyFile의 async-iterator 변형입니다(xet 기반 파일은 서버 측에서 복사되며 이벤트를 발생시키지 않습니다). 의미론은 copyFile을 참조하세요.
매개변수
| 이름 | 유형 |
|---|---|
params | { destination: CopyDestination ; source: CopySource } & SharedParams |
반환
AsyncGenerator<CopyProgressEvent, undefined>
Example
for await (const event of copyFileIter({ source, destination, accessToken })) {
console.log(`downloaded ${event.path} (${event.downloaded}/${event.total})`);
}정의 위치
packages/hub/src/lib/copy-files.ts:144
copyFiles
▸ copyFiles(params): Promise<undefined>
여러 파일(서로 다른 소스 저장소/버킷에서 가져온 경우 포함)을 단일 커밋으로 대상 버킷에 복사합니다.
xet 기반 소스 파일의 경우, 데이터 전송 없이 서버 측에서 복사가 수행됩니다. xet 기반이 아닌 소스 파일(일반적으로 작은 git 저장소 파일)의 경우, 해당 파일은 같은 커밋의 일부로 다운로드되고 다시 업로드됩니다.
xet으로 마이그레이션되지 않은 LFS 포인터 파일은 사전에 거부됩니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { destination: BucketDesignation ; files: CopyFilesEntry[] } & SharedParams |
반환
Promise<undefined>
Example
await copyFiles({
destination: { type: "bucket", name: "username/my-bucket" },
files: [
{
source: {
repo: { type: "bucket", name: "username/other-bucket" },
path: "data.bin",
},
destinationPath: "data.bin",
},
{
source: {
repo: { type: "model", name: "username/my-model" },
path: "model.safetensors",
},
destinationPath: "models/my-model/model.safetensors",
},
],
accessToken: "hf_...",
});정의 위치
packages/hub/src/lib/copy-files.ts:199
copyFilesIter
▸ copyFilesIter(params): AsyncGenerator<CopyProgressEvent, undefined>
비 xet 소스 파일을 다운로드하는 동안 CopyProgressEvent를 yield하는 copyFiles의 async-iterator 변형입니다(xet 기반 파일은 서버 측에서 복사되며 이벤트를 발생시키지 않습니다). 의미론은 copyFiles를 참조하세요.
매개변수
| 이름 | 유형 |
|---|---|
params | { destination: BucketDesignation ; files: CopyFilesEntry[] } & SharedParams |
반환
AsyncGenerator<CopyProgressEvent, undefined>
정의 위치
packages/hub/src/lib/copy-files.ts:219
copyFolder
▸ copyFolder(params): Promise<undefined>
소스 저장소/버킷에서 대상 버킷으로 폴더를 단일 커밋으로 재귀적으로 복사합니다.
파일별 경로는 CopySource.path를 기준으로 해석됩니다. CopyDestination.path가 소스 폴더를 유지하지 않는 한, 소스 폴더 자체는 대상에 보존되지 않습니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { destination: Omit<CopyDestination, "path"> & { path?: string } ; source: Omit<CopySource, "path"> & { path?: string } } & SharedParams |
반환
Promise<undefined>
Example
// Copy an entire dataset under "datasets/my-dataset/" in the bucket
await copyFolder({
source: { repo: { type: "dataset", name: "username/my-dataset" } },
destination: {
repo: { type: "bucket", name: "username/my-bucket" },
path: "datasets/my-dataset/",
},
accessToken: "hf_...",
});
// Copy a subfolder
await copyFolder({
source: {
repo: { type: "bucket", name: "username/src-bucket" },
path: "models/",
},
destination: {
repo: { type: "bucket", name: "username/dst-bucket" },
path: "backup/",
},
accessToken: "hf_...",
});정의 위치
packages/hub/src/lib/copy-files.ts:277
copyFolderIter
▸ copyFolderIter(params): AsyncGenerator<CopyProgressEvent, undefined>
비 xet 소스 파일을 다운로드하는 동안 CopyProgressEvent를 yield하는 copyFolder의 async-iterator 변형입니다(xet 기반 파일은 서버 측에서 복사되며 이벤트를 발생시키지 않습니다). 의미론은 copyFolder를 참조하세요.
매개변수
| 이름 | 유형 |
|---|---|
params | { destination: Omit<CopyDestination, "path"> & { path?: string } ; source: Omit<CopySource, "path"> & { path?: string } } & SharedParams |
반환
AsyncGenerator<CopyProgressEvent, undefined>
정의 위치
packages/hub/src/lib/copy-files.ts:297
countCommits
▸ countCommits(params): Promise<number>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<number>
정의 위치
packages/hub/src/lib/count-commits.ts:7
createBranch
▸ createBranch(params): Promise<void>
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
params | Object | - |
params.accessToken? | string | - |
params.branch | string | 생성할 브랜치의 이름 |
params.empty? | boolean | … |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> | MDN 참고 자료 |
params.hubUrl? | string | - |
params.overwrite? | boolean | 이 옵션은 이미 존재하는 브랜치를 덮어쓸 때 사용합니다. overwrite만 지정하고 revision/empty를 지정하지 않은 상태에서 해당 브랜치가 이미 존재하면 아무 동작도 수행하지 않습니다. |
params.repo | RepoDesignation | - |
params.revision? | string | Revision에서 브랜치를 생성할 기준입니다. 기본값은 기본 브랜치입니다. 빈 브랜치를 생성하려면 empty: true를 사용하세요. |
반환
Promise<void>
정의 위치
packages/hub/src/lib/create-branch.ts:6
createCollection
▸ createCollection(params): Promise<{ slug: string }>
매개변수
| 이름 | 유형 |
|---|---|
params | { collection: ApiCreateCollectionPayload ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string } & Partial<CredentialsParams> |
반환
Promise<{ slug: string }>
정의 위치
packages/hub/src/lib/create-collection.ts:7
createRepo
▸ createRepo(params): Promise<{ id: string ; repoUrl: string }>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; files?: { content: ArrayBuffer | Blob ; path: string }[] ; hardware?: SpaceHardwareFlavor | undefined ; hubUrl?: string ; license?: string ; private?: boolean ; repo: RepoDesignation ; resourceGroupId?: string ; sdk?: SpaceSdk | undefined ; visibility?: "public" | "private" | "protected" } & CredentialsParams |
반환
Promise<{ id: string ; repoUrl: string }>
정의 위치
packages/hub/src/lib/create-repo.ts:9
createScheduledJob
▸ createScheduledJob(params): Promise<ApiScheduledJob>
예약 작업을 생성합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; namespace: string } & CreateScheduledJobOptions & CredentialsParams |
반환
Promise<ApiScheduledJob>
정의 위치
packages/hub/src/lib/jobs/create-scheduled-job.ts:11
datasetInfo
▸ datasetInfo<T>(params): Promise<DatasetEntry & Pick<ApiDatasetInfo, T>>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | "author" | "cardData" | "disabled" | "gitalyUid" | "createdAt" | "tags" | "paperswithcode_id" | "sha" | "citation" | "description" | "downloadsAllTime"를 확장하며 never입니다 |
매개변수
| 이름 | 유형 |
|---|---|
params | { additionalFields?: T[] ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; name: string ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<DatasetEntry & Pick<ApiDatasetInfo, T>>
정의 위치
packages/hub/src/lib/dataset-info.ts:9
deleteBranch
▸ deleteBranch(params): Promise<void>
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
params | Object | - |
params.accessToken? | string | - |
params.branch | string | 삭제할 브랜치의 이름 |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> | MDN 참고 자료 |
params.hubUrl? | string | - |
params.repo | RepoDesignation | - |
반환
Promise<void>
정의 위치
packages/hub/src/lib/delete-branch.ts:6
deleteCollection
▸ deleteCollection(params): Promise<void>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; slug: string } & Partial<CredentialsParams> |
반환
Promise<void>
정의 위치
packages/hub/src/lib/delete-collection.ts:6
deleteFile
▸ deleteFile(params): Promise<CommitOutput | undefined>
매개변수
| 이름 | 유형 |
|---|---|
params | { branch?: string ; commitDescription?: string ; commitTitle?: string ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; isPullRequest?: boolean ; parentCommit?: string ; path: string ; repo: RepoDesignation } & CredentialsParams |
반환
Promise<CommitOutput | undefined>
정의 위치
packages/hub/src/lib/delete-file.ts:5
deleteFiles
▸ deleteFiles(params): Promise<CommitOutput | undefined>
매개변수
| 이름 | 유형 |
|---|---|
params | { branch?: string ; commitDescription?: string ; commitTitle?: string ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; isPullRequest?: boolean ; parentCommit?: string ; paths: string[] ; repo: RepoDesignation } & CredentialsParams |
반환
Promise<CommitOutput | undefined>
정의 위치
packages/hub/src/lib/delete-files.ts:5
deleteRepo
▸ deleteRepo(params): Promise<void>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; repo: RepoDesignation } & CredentialsParams |
반환
Promise<void>
정의 위치
packages/hub/src/lib/delete-repo.ts:7
deleteScheduledJob
▸ deleteScheduledJob(params): Promise<void>
예약된 작업을 삭제합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<void>
정의 위치
packages/hub/src/lib/jobs/delete-scheduled-job.ts:9
downloadFile
▸ downloadFile(params): Promise<Blob | null>
매개변수
| 이름 | 유형 |
|---|---|
params | { downloadInfo?: FileDownloadInfoOutput ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; parallelDownloads?: boolean | ParallelDownloadOptions ; path: string ; raw?: boolean ; repo: RepoDesignation ; revision?: string ; xet?: boolean | { readToken: XetReadToken } } & Partial<CredentialsParams> |
반환
Promise<Blob | null>
null 파일이 존재하지 않는 경우
정의 위치
packages/hub/src/lib/download-file.ts:13
downloadFileToCacheDir
▸ downloadFileToCacheDir(params): Promise<string>
local cache에 이미 존재하지 않는 경우 주어진 파일을 다운로드합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { cacheDir?: string ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; path: string ; raw?: boolean ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<string>
blob 객체에 대한 심볼릭 링크
정의 위치
packages/hub/src/lib/download-file-to-cache-dir.ts:46
duplicateJob
▸ duplicateJob(params): Promise<ApiJob>
…
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiJob>
정의 위치
packages/hub/src/lib/jobs/duplicate-job.ts:10
encodeShardFilename
▸ encodeShardFilename(filename): string
Defense in depth: 다운로드 URL은 문자열 보간으로 생성되므로, URL-safe라고 신뢰하기보다는 (이미 검증된) 파일명의 각 경로 세그먼트를 인코딩하세요.
매개변수
| 이름 | 유형 |
|---|---|
filename | string |
반환
string
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:570
fileDownloadInfo
▸ fileDownloadInfo(params): Promise<FileDownloadInfoOutput | null>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; noContentDisposition?: boolean ; path: string ; raw?: boolean ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<FileDownloadInfoOutput | null>
null 파일이 존재하지 않는 경우
정의 위치
packages/hub/src/lib/file-download-info.ts:27
fileExists
▸ fileExists(params): Promise<boolean>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; path: string ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<boolean>
정의 위치
packages/hub/src/lib/file-exists.ts:7
getBlobStat
▸ getBlobStat(blobPath, blobStats): Promise<Stats>
매개변수
| 이름 | 유형 |
|---|---|
blobPath | string |
blobStats | Map<string, Stats> |
반환
Promise<Stats>
정의 위치
packages/hub/src/lib/cache-management.ts:254
getHFHubCachePath
▸ getHFHubCachePath(): string
반환
string
정의 위치
packages/hub/src/lib/cache-management.ts:19
getJob
▸ getJob(params): Promise<ApiJob>
ID로 특정 작업을 가져옵니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiJob>
정의 위치
packages/hub/src/lib/jobs/get-job.ts:10
getQuantizationMultiplier
▸ getQuantizationMultiplier(tensorName, dtype, quantConfig?, expertDtype?, mlxQuantizedModules?): number
양자화 방법에 따라 양자화 텐서의 매개변수 배수를 가져옵니다.
소수일 수 있습니다 — packingFactor를 참조하세요.
매개변수
| 이름 | 유형 |
|---|---|
tensorName | string |
dtype | Dtype |
quantConfig? | QuantizationConfig |
expertDtype? | string |
mlxQuantizedModules? | ReadonlySet<string> |
반환
number
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:1259
getRepoFolderName
▸ getRepoFolderName(«destructured»): string
매개변수
| 이름 | 유형 |
|---|---|
«destructured» | RepoId |
반환
string
정의 위치
packages/hub/src/lib/cache-management.ts:27
getScheduledJob
▸ getScheduledJob(params): Promise<ApiScheduledJob>
ID로 특정 예약 작업을 가져옵니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiScheduledJob>
정의 위치
packages/hub/src/lib/jobs/get-scheduled-job.ts:10
globMatch
▸ globMatch(pattern, str): boolean
RegExp 없이 Glob 매칭: 패턴을 * 기준으로 분리하고, 각 리터럴 세그먼트가 str 내에서 순서대로 나타나는지 확인합니다. RegExp를 완전히 사용하지 않으므로 ReDoS 위험이 없으며, config.json의 공격자 제어 패턴으로 인한 SyntaxError도 발생하지 않습니다.
매개변수
| 이름 | 유형 |
|---|---|
pattern | string |
str | string |
반환
boolean
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:1153
isQuantizedTensor
▸ isQuantizedTensor(tensorName, quantConfig?, mlxQuantizedModules?): boolean
양자화 구성과 텐서 이름을 기반으로 텐서가 양자화되었는지 여부를 결정합니다.
Python의 transformers는 modules_to_not_convert에 대해 단순 부분 문자열 매칭을 사용하므로, "lm_head"와 같은 이름만으로는 "model.lm_head.weight"와 매칭되지 않습니다. 패턴에 *가 포함된 경우 유연성을 위해 적절한 glob 매칭으로 전환합니다.
매개변수
| 이름 | 유형 |
|---|---|
tensorName | string |
quantConfig? | QuantizationConfig |
mlxQuantizedModules? | ReadonlySet<string> |
반환
boolean
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:1189
listCollections
▸ listCollections(params?): AsyncGenerator<ApiCollectionInfo>
매개변수
| 이름 | 유형 |
|---|---|
params? | { search?: { owner?: string[] | undefined; item?: string[] | undefined; q?: string | undefined; } | undefined; sort?: “lastModified” | “trending” | “upvotes” | undefined; limit?: number | undefined; hubUrl?: string | undefined; fetch?: { …; } | undefined; } & Partial<…> |
반환
AsyncGenerator<ApiCollectionInfo>
정의 위치
packages/hub/src/lib/list-collections.ts:12
listCommits
▸ listCommits(params): AsyncGenerator<CommitData>
매개변수
| 이름 | 유형 |
|---|---|
params | { batchSize?: number ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
AsyncGenerator<CommitData>
정의 위치
packages/hub/src/lib/list-commits.ts:17
listDatasets
▸ listDatasets<T>(params?): AsyncGenerator<DatasetEntry & Pick<ApiDatasetInfo, T>>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | "author" | "cardData" | "disabled" | "gitalyUid" | "createdAt" | "tags" | "paperswithcode_id" | "sha" | "citation" | "description" | "downloadsAllTime"를 확장하며 never입니다 |
매개변수
| 이름 | 유형 |
|---|---|
params? | { search?: { query?: string | undefined; owner?: string | undefined; tags?: string[] | undefined; } | undefined; hubUrl?: string | undefined; additionalFields?: T[] | undefined; limit?: number | undefined; sort?: “id” | … 8 more … | undefined; fetch?: { …; } | undefined; } & Partial<…> |
반환
AsyncGenerator<DatasetEntry & Pick<ApiDatasetInfo, T>>
정의 위치
packages/hub/src/lib/list-datasets.ts:47
listFiles
▸ listFiles(params): AsyncGenerator<ListFileEntry>
폴더의 파일 목록을 표시합니다. 디렉터리의 모든 파일을 표시하려면 true로 params.recursive를 설정하여 호출합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { expand?: boolean ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; path?: string ; recursive?: boolean ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
AsyncGenerator<ListFileEntry>
정의 위치
packages/hub/src/lib/list-files.ts:53
listJobHardware
▸ listJobHardware(params?): Promise<ApiJobHardware[]>
작업에 사용할 수 있는 하드웨어 목록을 가져옵니다. 이 엔드포인트는 공개되어 있으며 인증이 필요하지 않지만, 인증은 선택 사항입니다.
매개변수
| 이름 | 유형 |
|---|---|
params? | { hubUrl?: string | undefined; fetch?: { (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response>; (input: string | … 1 more … | Request, init?: RequestInit | undefined): Promise<…>; } | undefined; } & Partial<…> |
반환
Promise<ApiJobHardware[]>
정의 위치
packages/hub/src/lib/jobs/list-job-hardware.ts:11
listJobs
▸ listJobs(params): Promise<ApiJob[]>
네임스페이스(사용자 또는 조직)의 작업을 나열합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiJob[]>
정의 위치
packages/hub/src/lib/jobs/list-jobs.ts:10
listModels
▸ listModels<T>(params?): AsyncGenerator<ModelEntry & ResolveModelAdditionalFields<T>>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | extends ModelAdditionalField = never |
매개변수
| 이름 | 유형 |
|---|---|
params? | { search?: { query?: string | undefined; owner?: string | undefined; task?: “other” | “text-classification” | “token-classification” | “table-question-answering” | “question-answering” | … 52 more … | undefined; tags?: string[] | undefined; inferenceProviders?: string[] | undefined; apps?: string[] | undefined; … |
반환
AsyncGenerator<ModelEntry & ResolveModelAdditionalFields<T>>
정의 위치
packages/hub/src/lib/list-models.ts:68
listScheduledJobs
▸ listScheduledJobs(params): Promise<ApiScheduledJob[]>
네임스페이스의 예약된 작업을 나열합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiScheduledJob[]>
정의 위치
packages/hub/src/lib/jobs/list-scheduled-jobs.ts:10
listSpaces
▸ listSpaces<T>(params?): AsyncGenerator<SpaceEntry & Pick<ApiSpaceInfo, T>>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | "models" | "datasets" | "author" | "cardData" | "disabled" | "gitalyUid" | "createdAt" | "tags" | "sha" | "subdomain" | "runtime"를 확장하는 never |
매개변수
| 이름 | 유형 |
|---|---|
params? | { search?: { query?: string | undefined; owner?: string | undefined; tags?: string[] | undefined; } | undefined; hubUrl?: string | undefined; fetch?: { (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<…>; (input: string | … 1 more … | Request, init?: RequestInit | undefined): Promise<…>; }… |
반환
AsyncGenerator<SpaceEntry & Pick<ApiSpaceInfo, T>>
정의 위치
packages/hub/src/lib/list-spaces.ts:44
matchesCompressedTensorsTarget
▸ matchesCompressedTensorsTarget(target, moduleName): boolean
압축된 텐서 대상과 모듈 이름을 일치시킵니다.
Targets는 정확한 모듈 이름, 클래스 이름(예: "Linear", 텐서 이름에서 해석할 수 없으므로 무시됨) 또는 re: 접두사가 붙은 Python 정규식입니다. config.json에서 공격자 제어 RegExp를 평가하는 것을 방지하기 위해(ReDoS, SyntaxError — globMatch 참조), 일반적인 정규식 부분집합(.* 와일드카드, ^/$ 앵커, \. 이스케이프)을 globMatch로 변환하고, 기타 정규식 문법을 사용하는 targets는 일치하지 않는 것으로 처리합니다.
매개변수
| 이름 | 유형 |
|---|---|
target | string |
moduleName | string |
반환
boolean
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:1231
modelInfo
▸ modelInfo<T>(params): Promise<ModelEntry & ResolveModelAdditionalFields<T>>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | extends ModelAdditionalField = never |
매개변수
| 이름 | 유형 |
|---|---|
params | { additionalFields?: T[] ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; name: string ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<ModelEntry & ResolveModelAdditionalFields<T>>
정의 위치
packages/hub/src/lib/model-info.ts:16
oauthHandleRedirect
▸ oauthHandleRedirect(opts?): Promise<OAuthResult>
OAuth 제공자가 앱으로 리디렉션한 후에 호출합니다.
URL의 쿼리 매개변수에 oauth 코드가 포함된 경우 oauthHandleRedirect를 호출하고, 그렇지 않으면 false를 반환하는 헬퍼 함수 oauthHandleRedirectIfPresent도 있습니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
opts? | Object | - |
opts.codeVerifier? | string | oauthLoginUrl에서 생성된 codeVerifier Default ts localStorage.getItem("huggingface.co:oauth:code_verifier") |
opts.hubUrl? | string | Hub의 URL입니다. 기본값은 HUB_URL입니다. |
opts.nonce? | string | oauthLoginUrl에서 생성된 nonce Default ts localStorage.getItem("huggingface.co:oauth:nonce") |
opts.redirectedUrl? | string | 분석할 URL입니다. Default ts window.location.href |
반환
Promise<OAuthResult>
정의 위치
packages/hub/src/lib/oauth-handle-redirect.ts:123
oauthHandleRedirectIfPresent
▸ oauthHandleRedirectIfPresent(opts?): Promise<OAuthResult | false>
OAuth 제공자가 앱으로 리디렉션한 후에 호출합니다.
URL의 쿼리 파라미터에 oauth 코드가 없으면 false를 반환하고, 그렇지 않으면 oauthHandleRedirect를 호출합니다.
앱에 따라 oauthHandleRedirect를 직접 호출하는 것이 더 적합할 수 있습니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
opts? | Object | - |
opts.codeVerifier? | string | oauthLoginUrl에서 생성된 codeVerifier Default ts localStorage.getItem("huggingface.co:oauth:code_verifier") |
opts.hubUrl? | string | Hub의 URL입니다. 기본값은 HUB_URL입니다. |
opts.nonce? | string | oauthLoginUrl에서 생성된 nonce Default ts localStorage.getItem("huggingface.co:oauth:nonce") |
opts.redirectedUrl? | string | 분석할 URL입니다. Default ts window.location.href |
반환
Promise<OAuthResult | false>
정의 위치
packages/hub/src/lib/oauth-handle-redirect.ts:293
oauthLoginUrl
▸ oauthLoginUrl(opts?): Promise<string>
“Sign in with Hub”를 사용하여 사용자를 인증하고 oauth 사용자 정보/액세스 토큰을 가져옵니다.
리다이렉트할 URL을 반환합니다. 사용자가 앱으로 리다이렉트된 후, oauthHandleRedirect를 호출하여 oauth 사용자 정보/액세스 토큰을 가져옵니다.
OAuth가 활성화된 정적 Space 내부에서 호출되면 Space에서 설정을 로드하고, 그렇지 않으면 OAuth App의 클라이언트 ID를 최소한 지정해야 합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
opts? | Object | - |
opts.clientId? | string | OAuth 클라이언트 ID. 정적 Spaces의 경우, README.md의 메타데이터에 hf_oauth: true가 존재하면 이 값을 생략할 수 있으며 Space 설정에서 로드됩니다. 다른 Spaces의 경우, README.md의 메타데이터에 hf_oauth: true가 존재하면 백엔드에서 OAUTH_CLIENT_ID 환경 변수로 사용할 수 있습니다. 또한 https://huggingface.co/settings/connected-applications에서 개발자 애플리케이션을 생성하여 해당 클라이언트 ID를 사용할 수도 있습니다. |
opts.hubUrl? | string | - |
opts.localStorage? | Object | 제공된 경우, localStorage를 사용하는 대신 OAuth 플로우에 사용된 code verifier와 nonce로 채워집니다. oauthHandleRedirectIfPresent 또는 oauthHandleRedirect를 호출할 때 동일한 값을 제공해야 합니다. |
opts.localStorage.codeVerifier? | string | - |
opts.localStorage.nonce? | string | - |
opts.redirectUrl? | string | Redirect URI, 기본값은 현재 URL입니다. Spaces의 경우 Space 내의 모든 URL이 허용됩니다. Developer Applications의 경우 https://huggingface.co/settings/connected-applications에서 허용되는 redirect URI 목록에 원하는 URL을 추가할 수 있습니다. |
opts.scopes? | string | OAuth scope, 공백으로 구분된 scope 목록입니다. 정적 Spaces의 경우, README.md의 메타데이터에 hf_oauth: true가 존재하는 한 이 항목을 생략할 수 있으며, Space config에서 로드됩니다. 다른 Spaces의 경우, README.md의 메타데이터에 hf_oauth: true가 존재하는 한 OAUTH_SCOPES 환경 변수를 통해 백엔드에서 사용할 수 있습니다. 기본값은 “openid profile”입니다. https://huggingface.co/settings/connected-applications에서 Developer Application을 생성하여 해당 scope를 사용할 수도 있습니다. 사용 가능한 scope 목록은 https://huggingface.co/docs/hub/oauth를 참고하세요. |
opts.state? | string | 리다이렉트 후 oauthLogin 호출 시 반환되는 OAuth 제공자에게 전달할 상태입니다. |
반환
Promise<string>
Example
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
const oauthResult = await oauthHandleRedirectIfPresent();
if (!oauthResult) {
// If the user is not logged in, redirect to the login page
window.location.href = await oauthLoginUrl();
}
// You can use oauthResult.accessToken, oauthResult.accessTokenExpiresAt and oauthResult.userInfo
console.log(oauthResult);(이론적으로 hubUrl을 변경하여 PKCE와 OpenID Connect를 지원하는 모든 OAuth 제공자에서 사용자 인증에 이 함수를 사용할 수 있지만, 현재는 Hugging Face Hub에서만 테스트되었습니다.)
정의 위치
packages/hub/src/lib/oauth-login-url.ts:31
parseRepoType
▸ parseRepoType(type): RepoType
매개변수
| 이름 | 유형 |
|---|---|
type | string |
반환
정의 위치
packages/hub/src/lib/cache-management.ts:264
parseSafetensorsMetadata
▸ parseSafetensorsMetadata(params): Promise<SetRequired<SafetensorsParseFromRepo, "parameterCount">>
Hugging Face에 호스팅된 모델의 model.safetensors.index.json 또는 model.safetensors를 스마트 레인지 요청을 사용하여 분석하여 메타데이터를 추출합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { computeParametersCount: true ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; library?: string ; path?: string ; repo: RepoDesignation ; revision?: string ; useSafetensorsMetadataEndpoint?: boolean } & Partial<CredentialsParams> |
반환
Promise<SetRequired<SafetensorsParseFromRepo, "parameterCount">>
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:738
▸ parseSafetensorsMetadata(params): Promise<SafetensorsParseFromRepo>
매개변수
| 이름 | 유형 |
|---|---|
params | { computeParametersCount?: boolean ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; library?: string ; path?: string ; repo: RepoDesignation ; revision?: string ; useSafetensorsMetadataEndpoint?: boolean } & Partial<CredentialsParams> |
반환
Promise<SafetensorsParseFromRepo>
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:775
parseSafetensorsShardFilename
▸ parseSafetensorsShardFilename(filename): SafetensorsShardFileInfo | null
매개변수
| 이름 | 유형 |
|---|---|
filename | string |
반환
SafetensorsShardFileInfo | null
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:36
parseTotalParameters
▸ parseTotalParameters(value, computedTotal?): number | undefined
total_parameters 단축키를 헤더/인덱스 메타데이터에서 읽습니다. 이는 자체 보고된 값이며, Hub는 이를 그대로 표시하여 위의 헤더 검증을 우회합니다. 따라서 계산된 값이 있는 경우 해당 값으로 상한을 설정합니다(두 값이 일치하는 잘 형성된 파일의 경우 이는 아무런 효과가 없습니다).
매개변수
| 이름 | 유형 |
|---|---|
value | undefined | string | number |
computedTotal? | number |
반환
number | undefined
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:699
pathsInfo
▸ pathsInfo(params): Promise<PathInfo & { lastCommit: CommitInfo ; securityFileStatus: SecurityFileStatus }[]>
매개변수
| 이름 | 유형 |
|---|---|
params | { expand: true ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; paths: string[] ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<PathInfo & { lastCommit: CommitInfo ; securityFileStatus: SecurityFileStatus }[]>
정의 위치
packages/hub/src/lib/paths-info.ts:51
▸ pathsInfo(params): Promise<PathInfo[]>
매개변수
| 이름 | 유형 |
|---|---|
params | { expand?: boolean ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; paths: string[] ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<PathInfo[]>
정의 위치
packages/hub/src/lib/paths-info.ts:64
relativeUnderFolder
▸ relativeUnderFolder(filePath, folderPath): string
filePath의 folderPath에 대한 상대 경로를 계산합니다. 복사 중인 폴더 아래에 있는 소스 경로를 새 접두사 아래에 있는 대상 경로로 매핑하는 데 사용됩니다.
매개변수
| 이름 | 유형 |
|---|---|
filePath | string |
folderPath | string |
반환
string
정의 위치
packages/hub/src/lib/copy-files.ts:558
repoExists
▸ repoExists(params): Promise<boolean>
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
params | Object | - |
params.accessToken? | string | - |
params.fetch? | (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> | 기본 함수 대신 사용할 커스텀 fetch 함수입니다. 예를 들어 프록시를 사용하거나 헤더를 수정하는 데 사용할 수 있습니다. |
params.hubUrl? | string | - |
params.repo | RepoDesignation | - |
params.revision? | string | 브랜치 이름, 태그 또는 커밋 해시일 수 있는 선택적 Git 리비전 ID입니다. |
반환
Promise<boolean>
정의 위치
packages/hub/src/lib/repo-exists.ts:6
resumeScheduledJob
▸ resumeScheduledJob(params): Promise<void>
예약된 작업을 재개합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<void>
정의 위치
packages/hub/src/lib/jobs/resume-scheduled-job.ts:9
runJob
▸ runJob(params): Promise<ApiJob>
새 작업을 실행합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; namespace: string } & CreateJobOptions & CredentialsParams |
반환
Promise<ApiJob>
정의 위치
packages/hub/src/lib/jobs/run-job.ts:12
runScheduledJob
▸ runScheduledJob(params): Promise<ApiJob | null>
예약된 작업을 즉시 실행하도록 트리거합니다. 트리거된 작업을 반환하며, 이미 다른 인스턴스가 실행 중이면 null을 반환합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<ApiJob | null>
정의 위치
packages/hub/src/lib/jobs/run-scheduled-job.ts:11
scanCacheDir
▸ scanCacheDir(cacheDir?): Promise<HFCacheInfo>
매개변수
| 이름 | 유형 | 기본값 |
|---|---|---|
cacheDir | undefined | string | undefined |
반환
Promise<HFCacheInfo>
정의 위치
packages/hub/src/lib/cache-management.ts:72
scanCachedRepo
▸ scanCachedRepo(repoPath): Promise<CachedRepoInfo>
매개변수
| 이름 | 유형 |
|---|---|
repoPath | string |
반환
Promise<CachedRepoInfo>
정의 위치
packages/hub/src/lib/cache-management.ts:118
scanRefsDir
▸ scanRefsDir(refsPath, refsByHash): Promise<void>
매개변수
| 이름 | 유형 |
|---|---|
refsPath | string |
refsByHash | Map<string, string[]> |
반환
Promise<void>
정의 위치
packages/hub/src/lib/cache-management.ts:210
scanSnapshotDir
▸ scanSnapshotDir(revisionPath, cachedFiles, blobStats): Promise<void>
매개변수
| 이름 | 유형 |
|---|---|
revisionPath | string |
cachedFiles | CachedFileInfo[] |
blobStats | Map<string, Stats> |
반환
Promise<void>
정의 위치
packages/hub/src/lib/cache-management.ts:227
snapshotDownload
▸ snapshotDownload(params): Promise<string>
지정된 리비전의 저장소 전체를 캐시 디렉터리 getHFHubCachePath에 다운로드합니다. scanCachedRepo를 사용하여 캐시된 모든 저장소를 나열할 수 있습니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { cacheDir?: string ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; repo: RepoDesignation ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<string>
Remarks
내부적으로 downloadFileToCacheDir를 사용합니다.
정의 위치
packages/hub/src/lib/snapshot-download.ts:20
spaceInfo
▸ spaceInfo<T>(params): Promise<SpaceEntry & Pick<ApiSpaceInfo, T>>
형식 매개변수
| 이름 | 유형 |
|---|---|
T | "models" | "datasets" | "author" | "cardData" | "disabled" | "gitalyUid" | "createdAt" | "tags" | "sha" | "subdomain" | "runtime"를 확장하는 never |
매개변수
| 이름 | 유형 |
|---|---|
params | { additionalFields?: T[] ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; name: string ; revision?: string } & Partial<CredentialsParams> |
반환
Promise<SpaceEntry & Pick<ApiSpaceInfo, T>>
정의 위치
packages/hub/src/lib/space-info.ts:10
streamJobEvents
▸ streamJobEvents(params): AsyncGenerator<string, void, unknown>
Server-Sent Events(SSE)를 사용하여 스트림 작업 이벤트를 전송합니다. 이벤트 청크의 비동기 반복 가능 객체를 반환합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
AsyncGenerator<string, void, unknown>
정의 위치
packages/hub/src/lib/jobs/stream-job-events.ts:10
streamJobLogs
▸ streamJobLogs(params): AsyncGenerator<{ message: string ; timestamp: Date }, void, unknown>
Server-Sent Events(SSE)를 사용하여 스트림 작업 로그를 전송합니다. 로그 청크의 비동기 반복 가능 객체를 반환합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
AsyncGenerator<{ message: string ; timestamp: Date }, void, unknown>
정의 위치
packages/hub/src/lib/jobs/stream-job-logs.ts:10
streamJobMetrics
▸ streamJobMetrics(params): AsyncGenerator<string, void, unknown>
Server-Sent Events(SSE)를 사용하여 스트림 작업 메트릭을 스트리밍합니다. 메트릭 청크의 비동기 반복 가능 객체를 반환합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
AsyncGenerator<string, void, unknown>
정의 위치
packages/hub/src/lib/jobs/stream-job-metrics.ts:10
streamJson
▸ streamJson(source, options?): AsyncGenerator<JsonStreamEvent, void, undefined>
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
source | ReadableStream<Uint8Array<ArrayBufferLike>> | AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | - |
options? | Object | - |
options.maxDepth? | number | 최대 객체/배열 중첩 깊이. Default ts 1_000 |
options.maxTokenLength? | number | 단일 문자열/숫자 토큰의 최대 길이(문자 단위). Default ts 16_000_000 |
반환
AsyncGenerator<JsonStreamEvent, void, undefined>
정의 위치
packages/hub/src/utils/streamJson.ts:123
suspendScheduledJob
▸ suspendScheduledJob(params): Promise<void>
예약된 작업을 일시중지합니다.
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string ; jobId: string ; namespace: string } & CredentialsParams |
반환
Promise<void>
정의 위치
packages/hub/src/lib/jobs/suspend-scheduled-job.ts:9
uploadFile
▸ uploadFile(params): Promise<CommitOutput | undefined>
매개변수
| 이름 | 유형 |
|---|---|
params | { abortSignal?: AbortSignal ; branch?: string ; commitDescription?: string ; commitTitle?: string ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; file: URL | CommitEditFileParams | File | { content: ContentSource ; path: string } ; hubUrl?: string ; isPullRequest?: boolean ; parentCommit?: string ; rangeEditCache?: RangeEditCache ; repo: RepoDesignation ; useWebWorkers?: boolean | { minSize?: number ; poolSize?: number } ; useXet?: boolean } & Partial<CredentialsParams> |
반환
Promise<CommitOutput | undefined>
정의 위치
packages/hub/src/lib/upload-file.ts:39
uploadFiles
▸ uploadFiles(params): Promise<CommitOutput | undefined>
매개변수
| 이름 | 유형 |
|---|---|
params | { abortSignal?: AbortSignal ; branch?: string ; commitDescription?: string ; commitTitle?: string ; fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; files: (URL | CommitEditFileParams | File | { content: ContentSource ; path: string })[] ; hubUrl?: string ; isPullRequest?: boolean ; maxFolderDepth?: number ; parentCommit?: string ; rangeEditCache?: RangeEditCache ; repo: RepoDesignation ; useWebWorkers?: boolean | { minSize?: number ; poolSize?: number } ; useXet?: boolean } & Partial<CredentialsParams> |
반환
Promise<CommitOutput | undefined>
정의 위치
packages/hub/src/lib/upload-files.ts:6
uploadFilesWithProgress
▸ uploadFilesWithProgress(params): AsyncGenerator<CommitProgressEvent, CommitOutput | undefined>
진행 상황 표시와 함께 업로드
모델, 데이터셋 및 스페이스 업로드의 진행 이벤트에 사용할 수 있도록 XMLHttpRequest가 필요합니다. 모델, 데이터셋 및 스페이스의 해싱 진행 이벤트를 사용하려면 useWebWorkers를 true로 설정하세요.
매개변수
| 이름 | 유형 |
|---|---|
params | { abortSignal?: AbortSignal ; branch?: string ; commitDescription?: string ; commitTitle?: string ; files: (URL | CommitEditFileParams | File | { content: ContentSource ; path: string })[] ; hubUrl?: string ; isPullRequest?: boolean ; maxFolderDepth?: number ; parentCommit?: string ; rangeEditCache?: RangeEditCache ; repo: RepoDesignation ; useWebWorkers?: boolean | { minSize?: number ; poolSize?: number } ; useXet?: boolean } & Partial<CredentialsParams> |
반환
AsyncGenerator<CommitProgressEvent, CommitOutput | undefined>
정의 위치
packages/hub/src/lib/upload-files-with-progress.ts:21
validateTensorEntry
▸ validateTensorEntry(path, tensorName, info, fileSizeBytes): void
MAX_TENSOR_DIM 이하의 유한한 정수인지, data_offsets가 합리적인 값인지, 그리고 파일 크기가 알려진 경우 선언된 바이트 범위가 파일 내에 들어맞는지 헤더의 텐서 항목 하나를 검증합니다. 패딩으로 인해 두 값이 정당하게 다를 수 있으므로 shape * dtype size 대신 data_offsets를 검사합니다. 포맷이 제공하는 유일한 기준은 오프셋이므로, 오프셋을 기준으로 검증합니다.
매개변수
| 이름 | 유형 |
|---|---|
path | string |
tensorName | string |
info | TensorInfo |
fileSizeBytes | undefined | number |
반환
void
정의 위치
packages/hub/src/lib/parse-safetensors-metadata.ts:246
whoAmI
▸ whoAmI(params): Promise<WhoAmI & { auth: AuthInfo }>
매개변수
| 이름 | 유형 |
|---|---|
params | { fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> ; hubUrl?: string } & CredentialsParams |
반환
Promise<WhoAmI & { auth: AuthInfo }>
정의 위치
packages/hub/src/lib/who-am-i.ts:62
Update on GitHub