Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
server fix
Browse files
src/routes/api/scrap-models/+server.ts
CHANGED
@@ -43,16 +43,15 @@ export async function POST({ request }) {
|
|
43 |
if (hasReadme) {
|
44 |
const readmeRes = await fetch(`https://huggingface.co/${model.id}/raw/main/README.md`)
|
45 |
const readme = await readmeRes.text().catch(() => null)
|
46 |
-
if (
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
|
56 |
}
|
57 |
}
|
58 |
}
|
@@ -62,7 +61,13 @@ export async function POST({ request }) {
|
|
62 |
await prisma.model.create({
|
63 |
data: {
|
64 |
id: model.id,
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
likes: model.likes,
|
67 |
downloads: model.downloads,
|
68 |
createdAt: model.createdAt,
|
|
|
43 |
if (hasReadme) {
|
44 |
const readmeRes = await fetch(`https://huggingface.co/${model.id}/raw/main/README.md`)
|
45 |
const readme = await readmeRes.text().catch(() => null)
|
46 |
+
if (readme) {
|
47 |
+
const imageRegex = /!\[.*\]\((.*)\)/
|
48 |
+
let image = readme.match(imageRegex)?.[1]
|
49 |
+
|
50 |
+
if (image) {
|
51 |
+
image = image.replace(///g, "/")
|
52 |
+
if (image.startsWith("http")) model.image = image
|
53 |
+
else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
|
54 |
+
}
|
|
|
55 |
}
|
56 |
}
|
57 |
}
|
|
|
61 |
await prisma.model.create({
|
62 |
data: {
|
63 |
id: model.id,
|
64 |
+
...(
|
65 |
+
model?.image?.startsWith("http") ? {
|
66 |
+
image: model.image
|
67 |
+
} : {
|
68 |
+
image: undefined,
|
69 |
+
}
|
70 |
+
),
|
71 |
likes: model.likes,
|
72 |
downloads: model.downloads,
|
73 |
createdAt: model.createdAt,
|