Huggingface.js documentation
接口:CommitEditFileParams
@huggingface/inference
使用 Inference ClientAPI 参考
类
HfInferenceInferenceClientInferenceClientEndpointInferenceClientErrorInferenceClientHubApiErrorInferenceClientInputErrorInferenceClientProviderApiErrorInferenceClientProviderOutputErrorInferenceClientRoutingError
接口
AudioToAudioOutputAudioToAudioOutputElemBaseArgsBodyParamsHeaderParamsInferenceProviderMappingEntryLogger选项TextGenerationInputTextGenerationOutputTextGenerationStreamBestOfSequenceTextGenerationStreamDetailsTextGenerationStreamOutputTextGenerationStreamPrefillTokenTextGenerationStreamTokenUrlParams
模块
@huggingface/hub
与 Hub 交互API 参考
类
接口
AuthInfoCachedFileInfoCachedRepoInfoCachedRevisionInfoCommitCopyFileCommitDataCommitDeletedEntryCommitEditFileCommitEditFileParamsCommitFileCommitInfoCommitOutputCopyDestinationCopyFilesEntryCopyProgressEventCopySource凭据DatasetEntryFileDownloadInfoOutputHFCacheInfoJobVolumeLfsPathInfoListFileEntryMlxQuantizationConfigModelConfigModelDerivedFieldsModelEntryOAuthResultParallelDownloadOptionsPathInfoQuantizationConfigRangeEditCacheEntryRepoIdSafetensorsIndexJsonSafetensorsShardFileInfoSecurityFileStatusSpaceEntrySpaceResourceConfigSpaceResourceRequirementSpaceRuntimeTensorInfoUserInfoWhoAmIAppWhoAmIOrgWhoAmIUserXetFileInfoXetReadToken
@huggingface/mcp-client
@huggingface/tiny-agents
@huggingface/space-header
@huggingface/gguf
@huggingface/lerobot
@huggingface/usd-web-viewer
接口:CommitEditFileParams
通过替换原始内容中的字节范围来编辑现有文件,而无需重新上传整个文件。
当 originalContent 来自基于 xet 的文件上的 downloadFile 时,未更改的部分既不会被下载,也不会被重新上传:仅传输已修改的字节范围(及其块边界附近区域)。当上传到存储桶时,此过程完全在远程执行——根本无需下载未更改的数据。
Example
const original = await downloadFile({ repo: "buckets/me/repo", path: "model.gguf" });
await uploadFile({
repo: "buckets/me/repo",
file: {
path: "model.gguf",
originalContent: original,
edits: [{ start: 0, end: 100, content: new Blob([patchedHeader]) }],
},
});属性
编辑
• edits:{ content:Blob ;end:number ;start:number }[]
定义于
packages/hub/src/lib/upload-file.ts:29
originalContent
• originalContent:Blob
该文件的当前内容,例如由 downloadFile 返回的内容
定义于
packages/hub/src/lib/upload-file.ts:28
path
• path:string
定义于
packages/hub/src/lib/upload-file.ts:26
Update on GitHub