save changes

This commit is contained in:
2025-09-22 22:22:57 +02:00
parent e5a65114d1
commit 78584ce1b6
3 changed files with 28 additions and 4 deletions

View File

@ -41,6 +41,11 @@ async function callOpenAI(prompt: string): Promise<any> {
const jsonMatch = content.match(/\{[\s\S]*\}/);
if (jsonMatch) {
return JSON.parse(jsonMatch[0]);
} else {
const arrayMatch = content.match(/\[[\s\S]*\]/);
if (arrayMatch) {
return JSON.parse(arrayMatch[0]);
}
}
} else {
logger.error('Unexpected API response:', data);
@ -94,6 +99,11 @@ async function callOpenAIWithFile(imagePath: string, prompt: string): Promise<an
const jsonMatch = content.match(/\{[\s\S]*\}/);
if (jsonMatch) {
return JSON.parse(jsonMatch[0]);
} else {
const arrayMatch = content.match(/\[[\s\S]*\]/);
if (arrayMatch) {
return JSON.parse(arrayMatch[0]);
}
}
} else {
logger.error('Unexpected API response:', data);