Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
add base_model field
Browse files
prisma/schema.prisma
CHANGED
@@ -22,6 +22,7 @@ model Model {
|
|
22 |
user User? @relation(fields: [userId], references: [sub])
|
23 |
userId String?
|
24 |
metadata String?
|
|
|
25 |
gallery Gallery[]
|
26 |
comments Comment[]
|
27 |
}
|
|
|
22 |
user User? @relation(fields: [userId], references: [sub])
|
23 |
userId String?
|
24 |
metadata String?
|
25 |
+
base_model String?
|
26 |
gallery Gallery[]
|
27 |
comments Comment[]
|
28 |
}
|
src/lib/components/models/drawer/Drawer.svelte
CHANGED
@@ -147,7 +147,7 @@
|
|
147 |
</div>
|
148 |
<div class="px-4 py-3">
|
149 |
<p class="text-neutral-400 uppercase text-[10px]">base_model</p>
|
150 |
-
<p class="text-neutral-100 font-medium text-base mt-0.5">{model?.
|
151 |
</div>
|
152 |
</div>
|
153 |
{/if}
|
|
|
147 |
</div>
|
148 |
<div class="px-4 py-3">
|
149 |
<p class="text-neutral-400 uppercase text-[10px]">base_model</p>
|
150 |
+
<p class="text-neutral-100 font-medium text-base mt-0.5">{model?.base_model ?? 'N/A'}</p>
|
151 |
</div>
|
152 |
</div>
|
153 |
{/if}
|
src/lib/type.ts
CHANGED
@@ -24,6 +24,7 @@ export interface ModelCard {
|
|
24 |
image: string,
|
25 |
instance_prompt?: string,
|
26 |
metadata?: string,
|
|
|
27 |
isPublic: boolean,
|
28 |
gallery?: CommunityCard[],
|
29 |
comments?: CommentType[],
|
|
|
24 |
image: string,
|
25 |
instance_prompt?: string,
|
26 |
metadata?: string,
|
27 |
+
base_model?: string,
|
28 |
isPublic: boolean,
|
29 |
gallery?: CommunityCard[],
|
30 |
comments?: CommentType[],
|
src/routes/api/models/+server.ts
CHANGED
@@ -89,6 +89,8 @@ export async function PATCH({ request } : RequestEvent) {
|
|
89 |
|
90 |
}
|
91 |
|
|
|
|
|
92 |
if (!hugging_face_model?.[0]) {
|
93 |
continue;
|
94 |
}
|
@@ -104,6 +106,10 @@ export async function PATCH({ request } : RequestEvent) {
|
|
104 |
...(hugging_face_model2?.cardData?.instance_prompt ? {
|
105 |
instance_prompt: hugging_face_model2?.cardData?.instance_prompt,
|
106 |
} : {}
|
|
|
|
|
|
|
|
|
107 |
)
|
108 |
}
|
109 |
})
|
|
|
89 |
|
90 |
}
|
91 |
|
92 |
+
const base_model = hugging_face_model.tags.find((tag: string) => tag.startsWith("base_model:"))?.split(":")[1] ?? null
|
93 |
+
|
94 |
if (!hugging_face_model?.[0]) {
|
95 |
continue;
|
96 |
}
|
|
|
106 |
...(hugging_face_model2?.cardData?.instance_prompt ? {
|
107 |
instance_prompt: hugging_face_model2?.cardData?.instance_prompt,
|
108 |
} : {}
|
109 |
+
),
|
110 |
+
...(base_model ? {
|
111 |
+
base_model: base_model
|
112 |
+
} : {}
|
113 |
)
|
114 |
}
|
115 |
})
|
src/routes/api/models/[id]/+server.ts
CHANGED
@@ -25,6 +25,7 @@ export async function GET({ url, params } : RequestEvent) {
|
|
25 |
image: true,
|
26 |
instance_prompt: true,
|
27 |
metadata: true,
|
|
|
28 |
gallery: {
|
29 |
select: {
|
30 |
id: true,
|
@@ -179,13 +180,19 @@ export async function POST({ params, cookies, fetch } : RequestEvent) {
|
|
179 |
const data = await fetch(`https://huggingface.co/api/models/${model.id}`)
|
180 |
const hf_model = await data.json()
|
181 |
|
|
|
|
|
182 |
await prisma.model.update({
|
183 |
where: {
|
184 |
id,
|
185 |
},
|
186 |
data: {
|
187 |
isPublic: true,
|
188 |
-
instance_prompt: hf_model?.cardData?.instance_prompt
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
})
|
191 |
|
|
|
25 |
image: true,
|
26 |
instance_prompt: true,
|
27 |
metadata: true,
|
28 |
+
base_model: true,
|
29 |
gallery: {
|
30 |
select: {
|
31 |
id: true,
|
|
|
180 |
const data = await fetch(`https://huggingface.co/api/models/${model.id}`)
|
181 |
const hf_model = await data.json()
|
182 |
|
183 |
+
const base_model = hf_model.tags.find((tag: string) => tag.startsWith("base_model:"))?.split(":")[1] ?? null
|
184 |
+
|
185 |
await prisma.model.update({
|
186 |
where: {
|
187 |
id,
|
188 |
},
|
189 |
data: {
|
190 |
isPublic: true,
|
191 |
+
instance_prompt: hf_model?.cardData?.instance_prompt,
|
192 |
+
...(base_model ? {
|
193 |
+
base_model: base_model
|
194 |
+
} : {}
|
195 |
+
)
|
196 |
}
|
197 |
})
|
198 |
|
src/routes/api/scrap-models/+server.ts
CHANGED
@@ -58,6 +58,8 @@ export async function POST({ request }) {
|
|
58 |
}
|
59 |
}
|
60 |
|
|
|
|
|
61 |
await prisma.model.create({
|
62 |
data: {
|
63 |
id: model.id,
|
@@ -66,6 +68,10 @@ export async function POST({ request }) {
|
|
66 |
downloads: model.downloads,
|
67 |
createdAt: model.createdAt,
|
68 |
isPublic: false,
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
})
|
71 |
.then(() => {
|
|
|
58 |
}
|
59 |
}
|
60 |
|
61 |
+
const base_model = model.tags.find((tag: string) => tag.startsWith("base_model:"))?.split(":")[1] ?? null
|
62 |
+
|
63 |
await prisma.model.create({
|
64 |
data: {
|
65 |
id: model.id,
|
|
|
68 |
downloads: model.downloads,
|
69 |
createdAt: model.createdAt,
|
70 |
isPublic: false,
|
71 |
+
...(base_model ? {
|
72 |
+
base_model: base_model
|
73 |
+
} : {}
|
74 |
+
)
|
75 |
}
|
76 |
})
|
77 |
.then(() => {
|