enzostvs HF staff commited on
Commit
b0122ad
β€’
1 Parent(s): 6d8d7d2

change updated models routes

Browse files
package-lock.json CHANGED
@@ -9,7 +9,7 @@
9
  "version": "0.0.1",
10
  "dependencies": {
11
  "@aws-sdk/client-s3": "^3.490.0",
12
- "@huggingface/hub": "^0.12.3-oauth",
13
  "@iconify/svelte": "^3.1.4",
14
  "@prisma/client": "^5.7.1",
15
  "@svelte-put/clickoutside": "^3.0.1",
@@ -56,6 +56,29 @@
56
  "vite": "^4.4.2"
57
  }
58
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  "node_modules/@aashutoshrathi/word-wrap": {
60
  "version": "1.2.6",
61
  "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz",
@@ -1254,9 +1277,9 @@
1254
  "dev": true
1255
  },
1256
  "node_modules/@huggingface/hub": {
1257
- "version": "0.12.3-oauth",
1258
- "resolved": "https://registry.npmjs.org/@huggingface/hub/-/hub-0.12.3-oauth.tgz",
1259
- "integrity": "sha512-9LE4Ded2VsjQTK/rxsIF/nvhkxs1UE+lcpNpuBxnTGNpaVzbO6HIlAtbThgNenKPplRt1iDkn82AQYBco1QHug==",
1260
  "dependencies": {
1261
  "hash-wasm": "^4.9.0"
1262
  },
 
9
  "version": "0.0.1",
10
  "dependencies": {
11
  "@aws-sdk/client-s3": "^3.490.0",
12
+ "@huggingface/hub": "^0.12.3",
13
  "@iconify/svelte": "^3.1.4",
14
  "@prisma/client": "^5.7.1",
15
  "@svelte-put/clickoutside": "^3.0.1",
 
56
  "vite": "^4.4.2"
57
  }
58
  },
59
+ "../@huggingface-mini-header": {
60
+ "name": "@huggingface/space-header",
61
+ "version": "1.0.0",
62
+ "extraneous": true,
63
+ "license": "ISC",
64
+ "devDependencies": {
65
+ "tsup": "^8.1.0",
66
+ "typescript": "^5.4.5"
67
+ }
68
+ },
69
+ "../huggingface.js/packages/space-header": {
70
+ "name": "@huggingface/space-header",
71
+ "version": "1.0.0",
72
+ "extraneous": true,
73
+ "license": "ISC",
74
+ "devDependencies": {
75
+ "tsup": "^8.1.0",
76
+ "typescript": "^5.4.5"
77
+ }
78
+ },
79
+ "../huggingface.js/space-header": {
80
+ "extraneous": true
81
+ },
82
  "node_modules/@aashutoshrathi/word-wrap": {
83
  "version": "1.2.6",
84
  "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz",
 
1277
  "dev": true
1278
  },
1279
  "node_modules/@huggingface/hub": {
1280
+ "version": "0.12.3",
1281
+ "resolved": "https://registry.npmjs.org/@huggingface/hub/-/hub-0.12.3.tgz",
1282
+ "integrity": "sha512-QvK7YSKktrNu/Vyr/oAL2xcCwCiNcf4hPfzra6/jtNNK0GAZXwqOYwB+Kt2hil/XShh1e5cGWDTyKPU5K7zCUA==",
1283
  "dependencies": {
1284
  "hash-wasm": "^4.9.0"
1285
  },
package.json CHANGED
@@ -42,7 +42,7 @@
42
  "type": "module",
43
  "dependencies": {
44
  "@aws-sdk/client-s3": "^3.490.0",
45
- "@huggingface/hub": "^0.12.3-oauth",
46
  "@iconify/svelte": "^3.1.4",
47
  "@prisma/client": "^5.7.1",
48
  "@svelte-put/clickoutside": "^3.0.1",
 
42
  "type": "module",
43
  "dependencies": {
44
  "@aws-sdk/client-s3": "^3.490.0",
45
+ "@huggingface/hub": "^0.12.3",
46
  "@iconify/svelte": "^3.1.4",
47
  "@prisma/client": "^5.7.1",
48
  "@svelte-put/clickoutside": "^3.0.1",
src/hooks.server.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** @type {import('@sveltejs/kit').HandleServerError} */
2
+ export async function handle({ event, resolve }) {
3
+ const request = event.request;
4
+ const url = new URL(request.url);
5
+ if (url.pathname === "/") {
6
+ return new Response(null, {
7
+ status: 302,
8
+ headers: {
9
+ location: "/models"
10
+ }
11
+ });
12
+ }
13
+ return resolve(event);
14
+
15
+ }
src/lib/utils/index.ts CHANGED
@@ -39,7 +39,7 @@ export const MODELS_FILTER_OPTIONS = [
39
  export const SIDEBAR_MENUS = [ {
40
  icon: "uim:cube",
41
  label: "Models",
42
- href: "/",
43
  }, {
44
  icon: "solar:gallery-bold-duotone",
45
  label: "Gallery",
 
39
  export const SIDEBAR_MENUS = [ {
40
  icon: "uim:cube",
41
  label: "Models",
42
+ href: "/models",
43
  }, {
44
  icon: "solar:gallery-bold-duotone",
45
  label: "Gallery",
src/lib/utils/upload_image.ts CHANGED
@@ -34,7 +34,6 @@ export const uploadImage = async (file: {
34
  try {
35
  // await client.send(putCommand)
36
  const data = await client.send(command);
37
- console.log(data);
38
  // console.log('Successfully uploaded data to ' + bucketName + '/' + keyName)
39
  } catch (err: any) {
40
  console.error(err, err.stack)
 
34
  try {
35
  // await client.send(putCommand)
36
  const data = await client.send(command);
 
37
  // console.log('Successfully uploaded data to ' + bucketName + '/' + keyName)
38
  } catch (err: any) {
39
  console.error(err, err.stack)
src/routes/+page.server.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { redirect } from '@sveltejs/kit';
2
 
3
  /** @type {import('./$types').PageLoad} */
4
  export async function load() {
5
- throw redirect(302, "/models")
6
  }
 
1
+ // import { redirect } from '@sveltejs/kit';
2
 
3
  /** @type {import('./$types').PageLoad} */
4
  export async function load() {
5
+ // throw redirect(302, "/models")
6
  }
src/routes/api/models/+server.ts CHANGED
@@ -70,20 +70,25 @@ export async function PATCH({ request } : RequestEvent) {
70
  }, { status: 401 });
71
  }
72
 
73
- const hf_request = await fetch(`https://huggingface.co/api/models?limit=10000&filter=lora%2Cdiffusers&sort=likes7d`)
74
- const hf_models = await hf_request.json();
75
 
76
  let total_updates = 0;
77
 
78
- for (const model of hf_models) {
 
 
 
 
 
 
79
  await prisma.model.update({
80
  where: {
81
  id: model.id
82
  },
83
  data: {
84
- likes: model.likes,
85
- downloads: model.downloads,
86
- likes7d: model.likes7d,
87
  }
88
  })
89
  .then(() => {
 
70
  }, { status: 401 });
71
  }
72
 
73
+ const models = await prisma.model.findMany();
 
74
 
75
  let total_updates = 0;
76
 
77
+ for (const model of models) {
78
+ const hugging_face_request = await fetch(`https://huggingface.co/api/models/${model.id}`)
79
+ const hugging_face_model = await hugging_face_request.json()?.catch(() => {})
80
+
81
+ if (!hugging_face_model) {
82
+ continue;
83
+ }
84
  await prisma.model.update({
85
  where: {
86
  id: model.id
87
  },
88
  data: {
89
+ likes: hugging_face_model.likes,
90
+ downloads: hugging_face_model.downloads,
91
+ likes7d: hugging_face_model.likes7d,
92
  }
93
  })
94
  .then(() => {
src/routes/gallery/[id]/+page.svelte CHANGED
@@ -5,7 +5,6 @@
5
 
6
 
7
  onMount(() => {
8
- console.log(data)
9
  galleryStore.set({
10
  gallery: data.gallery,
11
  open: true,
 
5
 
6
 
7
  onMount(() => {
 
8
  galleryStore.set({
9
  gallery: data.gallery,
10
  open: true,
src/routes/models/+layout.svelte CHANGED
@@ -2,6 +2,8 @@
2
  import { browser } from "$app/environment";
3
  import InfiniteScroll from "svelte-infinite-scroll";
4
  import { page } from "$app/stores";
 
 
5
 
6
  import { goto } from "$app/navigation";
7
  import Button from "$lib/components/Button.svelte";
@@ -10,13 +12,9 @@
10
  import Radio from "$lib/components/fields/Radio.svelte";
11
  import { MODELS_FILTER_OPTIONS } from "$lib/utils/index.js";
12
  import GoTop from "$lib/components/GoTop.svelte";
13
- import Dialog from "$lib/components/dialog/Dialog.svelte";
14
- import SubmitModel from "$lib/components/models/Submit.svelte";
15
  import Drawer from "$lib/components/models/drawer/Drawer.svelte";
16
- import { onMount } from "svelte";
17
  import type { ModelCard } from "$lib/type";
18
  import { userStore } from "$lib/stores/use-user";
19
- import Add from "$lib/components/community/reactions/Add.svelte";
20
 
21
  let data: {
22
  models: ModelCard[],
@@ -35,9 +33,7 @@
35
 
36
  onMount(() => {
37
  refetch(false);
38
- if ($page.url.searchParams.get('model')) {
39
- // getModel($page.url.searchParams.get('model') as string);
40
- }
41
  });
42
 
43
  $: elementScroll = browser ? document?.getElementById('app') : undefined;
 
2
  import { browser } from "$app/environment";
3
  import InfiniteScroll from "svelte-infinite-scroll";
4
  import { page } from "$app/stores";
5
+ import { onMount } from "svelte";
6
+ // import { init } from "@huggingface/space-header";
7
 
8
  import { goto } from "$app/navigation";
9
  import Button from "$lib/components/Button.svelte";
 
12
  import Radio from "$lib/components/fields/Radio.svelte";
13
  import { MODELS_FILTER_OPTIONS } from "$lib/utils/index.js";
14
  import GoTop from "$lib/components/GoTop.svelte";
 
 
15
  import Drawer from "$lib/components/models/drawer/Drawer.svelte";
 
16
  import type { ModelCard } from "$lib/type";
17
  import { userStore } from "$lib/stores/use-user";
 
18
 
19
  let data: {
20
  models: ModelCard[],
 
33
 
34
  onMount(() => {
35
  refetch(false);
36
+ // init("enzostvs/lora-studio");
 
 
37
  });
38
 
39
  $: elementScroll = browser ? document?.getElementById('app') : undefined;
svelte.config.js CHANGED
@@ -17,6 +17,11 @@ const config = {
17
  }) : adapterNode({
18
  out: 'build',
19
  }),
 
 
 
 
 
20
  },
21
  };
22
 
 
17
  }) : adapterNode({
18
  out: 'build',
19
  }),
20
+ prerender: {
21
+ entries: [
22
+ '*',
23
+ ]
24
+ }
25
  },
26
  };
27