This commit is contained in:
KS Jannette
2026-02-13 13:42:31 -05:00
parent 2212755772
commit 534da11217
3 changed files with 23 additions and 8 deletions

View File

@@ -40,6 +40,15 @@ export const clusterNotes = async (notes) => {
],
});
const raw = response.content[0].text;
return JSON.parse(raw);
const textBlock = response?.content?.[0];
if (!textBlock || textBlock.type !== 'text' || typeof textBlock.text !== 'string') {
throw new Error('Unexpected response from LLM API: no text content returned');
}
try {
return JSON.parse(textBlock.text);
} catch {
throw new Error('LLM API returned non-JSON response');
}
};