save changes
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user