fix ki modell
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user