Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
set instance prompt only at the generation
Browse files
src/routes/api/generate/+server.ts
CHANGED
@@ -29,6 +29,15 @@ export async function POST({ request, cookies } : RequestEvent) {
|
|
29 |
}, { status: 400 })
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
const response = await fetch(env.SECRET_INFERENCE_API_URL + "/models/" + generation?.model?.id, {
|
33 |
method: "POST",
|
34 |
headers: {
|
@@ -36,7 +45,10 @@ export async function POST({ request, cookies } : RequestEvent) {
|
|
36 |
'Content-Type': 'application/json',
|
37 |
['x-use-cache']: "0"
|
38 |
},
|
39 |
-
body: JSON.stringify(
|
|
|
|
|
|
|
40 |
})
|
41 |
.then((response) => {
|
42 |
return response.arrayBuffer()
|
|
|
29 |
}, { status: 400 })
|
30 |
}
|
31 |
|
32 |
+
const model = await prisma.model.findFirst({
|
33 |
+
where: {
|
34 |
+
id: generation.model.id
|
35 |
+
},
|
36 |
+
select: {
|
37 |
+
instance_prompt: true,
|
38 |
+
}
|
39 |
+
})
|
40 |
+
|
41 |
const response = await fetch(env.SECRET_INFERENCE_API_URL + "/models/" + generation?.model?.id, {
|
42 |
method: "POST",
|
43 |
headers: {
|
|
|
45 |
'Content-Type': 'application/json',
|
46 |
['x-use-cache']: "0"
|
47 |
},
|
48 |
+
body: JSON.stringify({
|
49 |
+
...generation,
|
50 |
+
inputs: `${(model?.instance_prompt || "")} ${generation.inputs}`,
|
51 |
+
}),
|
52 |
})
|
53 |
.then((response) => {
|
54 |
return response.arrayBuffer()
|
src/routes/generate/+page.svelte
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
|
21 |
let form = ((data?.model?.id && generation?.form?.model?.id && data?.model?.id !== generation?.form?.model?.id) || !generation?.form) ? {
|
22 |
model: data?.model ?? null,
|
23 |
-
inputs:
|
24 |
parameters: {
|
25 |
negative_prompt: ""
|
26 |
}
|
@@ -65,7 +65,6 @@
|
|
65 |
defaultModels={data?.models?.cards}
|
66 |
onChange={(model) => {
|
67 |
form.model = model
|
68 |
-
if (model?.instance_prompt) form.inputs = model.instance_prompt
|
69 |
}}
|
70 |
/>
|
71 |
</div>
|
|
|
20 |
|
21 |
let form = ((data?.model?.id && generation?.form?.model?.id && data?.model?.id !== generation?.form?.model?.id) || !generation?.form) ? {
|
22 |
model: data?.model ?? null,
|
23 |
+
inputs: "",
|
24 |
parameters: {
|
25 |
negative_prompt: ""
|
26 |
}
|
|
|
65 |
defaultModels={data?.models?.cards}
|
66 |
onChange={(model) => {
|
67 |
form.model = model
|
|
|
68 |
}}
|
69 |
/>
|
70 |
</div>
|