ai-tube / src /app /server /actions /ai-tube-hf /deleteFileFromDataset.ts
jbilcke-hf's picture
jbilcke-hf HF staff
hide some features for the beta + improve player
f27679f
raw
history blame
No virus
781 Bytes
import { deleteFile } from "@/huggingface/hub/src"
import { getCredentials } from "./getCredentials"
export async function deleteFileFromDataset({
repo,
path,
apiKey,
neverThrow = false
}: {
repo: string
path: string
apiKey?: string
/**
* If set to true, this function will never throw an exception
* this is useful in workflow where we don't care about what happened
*
* False by default
*/
neverThrow?: boolean
}): Promise<boolean> {
try {
const { credentials } = await getCredentials(apiKey)
await deleteFile({
repo,
path,
credentials
})
return true
} catch (err) {
if (neverThrow) {
console.error(`deleteFileFromDataset():`, err)
return false
} else {
throw err
}
}
}