enzostvs HF staff commited on
Commit
2401f68
β€’
1 Parent(s): cca5650

save instance prompt at publish

Browse files
src/routes/api/models/[id]/+server.ts CHANGED
@@ -89,7 +89,7 @@ export async function GET({ url, params } : RequestEvent) {
89
  })
90
  }
91
 
92
- export async function POST({ params, cookies } : RequestEvent) {
93
  const token = cookies.get('hf_access_token')
94
  if (!token) {
95
  return json({
@@ -100,7 +100,7 @@ export async function POST({ params, cookies } : RequestEvent) {
100
  }
101
 
102
  const user = await tokenIsAvailable(token)
103
- if (!user || !process.env.SECRET_HF_ADMIN.includes(user.sub)) {
104
  return json({
105
  error: {
106
  token: "Wrong castle fam :^)"
@@ -124,12 +124,16 @@ export async function POST({ params, cookies } : RequestEvent) {
124
  }, { status: 404 })
125
  }
126
 
 
 
 
127
  await prisma.model.update({
128
  where: {
129
  id,
130
  },
131
  data: {
132
  isPublic: true,
 
133
  }
134
  })
135
 
 
89
  })
90
  }
91
 
92
+ export async function POST({ params, cookies, fetch } : RequestEvent) {
93
  const token = cookies.get('hf_access_token')
94
  if (!token) {
95
  return json({
 
100
  }
101
 
102
  const user = await tokenIsAvailable(token)
103
+ if (!user || !process.env.SECRET_HF_ADMIN?.includes(user.sub)) {
104
  return json({
105
  error: {
106
  token: "Wrong castle fam :^)"
 
124
  }, { status: 404 })
125
  }
126
 
127
+ const data = await fetch(`https://huggingface.co/api/models/${model.id}`)
128
+ const hf_model = await data.json()
129
+
130
  await prisma.model.update({
131
  where: {
132
  id,
133
  },
134
  data: {
135
  isPublic: true,
136
+ instance_prompt: hf_model?.cardData?.instance_prompt
137
  }
138
  })
139