File size: 722 Bytes
416e7d7
 
 
7bf2ef2
 
416e7d7
 
 
 
 
 
 
 
 
7bf2ef2
416e7d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { uploadFiles, RepoDesignation, Credentials } from "@huggingface/hub"

export const UploaderDataset = async (results: Array<{
  file_name: string;
  prompt: string;
}>, blobs: Array<Blob>) => {
  const repo: RepoDesignation = { type: "dataset", name: "enzostvs/what-is-the-prompt" };
  const credentials: Credentials = { accessToken: process.env.HF_TOKEN as string };

  const res: any = await uploadFiles({
    repo,
    credentials,
    files: results.map((result, i) => {
      return {
        path: result.file_name,
        content: blobs[i],
      }
    })
  });

  if (res?.data?.error) return {
    status: 500,
    ok: false,
    error: res?.error
  };  

  return {
    status: 200,
    ok: true,
  };

}