fix ki modell

This commit is contained in:
nadja
2026-08-26 18:49:44 +02:00
parent e60da3daf6
commit c0c3421f33
2 changed files with 14 additions and 13 deletions

View File

@@ -36,5 +36,12 @@ export async function extractRecipe(description) {
text = text.replace(/^```(?:json)?\n?/, '').replace(/\n?```$/, '');
}
const jsonStart = text.indexOf('{');
const jsonEnd = text.lastIndexOf('}');
if (jsonStart === -1 || jsonEnd === -1 || jsonEnd <= jsonStart) {
throw new Error('Kein valides JSON in der Modell-Antwort');
}
text = text.slice(jsonStart, jsonEnd + 1);
return JSON.parse(text);
}