feat: allow reference images for AI layer edits and relax stylistic constraints to allow for realism
Build and Deploy / build-and-push (push) Successful in 2m9s

This commit is contained in:
AI Bot
2026-10-05 15:27:59 +05:30
parent f44a07b1a9
commit 527dfba535
3 changed files with 112 additions and 21 deletions
+10 -2
View File
@@ -80,7 +80,7 @@ export async function pollStatus<T>(
throw new Error("Polling timeout exceeded.");
}
export async function editUVLayer(prompt: string, imageBase64: string, token: string): Promise<string> {
export async function editUVLayer(prompt: string, imageBase64: string, token: string, referenceImageBase64?: string): Promise<string> {
// Extract mime type if present in the data URI
let mimeType = 'image/png';
if (imageBase64.startsWith('data:')) {
@@ -90,13 +90,21 @@ export async function editUVLayer(prompt: string, imageBase64: string, token: st
}
}
let referenceMimeType;
if (referenceImageBase64 && referenceImageBase64.startsWith('data:')) {
const match = referenceImageBase64.match(/^data:([^;]+);/);
if (match) {
referenceMimeType = match[1];
}
}
const response = await fetch('/api/sparkplug/edit-layer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({ prompt, imageBase64, mimeType })
body: JSON.stringify({ prompt, imageBase64, mimeType, referenceImageBase64, referenceMimeType })
});
if (!response.ok) {