adding in entity extraction layer
This commit is contained in:
@@ -43,11 +43,13 @@ async function extractAndStoreEntities(userMessage, aiResponse) {
|
||||
if (!res.ok) throw new Error(`Ollama responded ${res.status}`);
|
||||
|
||||
const data = await res.json();
|
||||
console.log('[entities] Raw response:', data.response?.slice(0, 200));
|
||||
const raw = data.response?.trim() ?? '';
|
||||
|
||||
// Strip markdown fences defensively — small models sometimes add them anyway
|
||||
const clean = raw.replace(/^```(?:json)?\n?/, '').replace(/\n?```$/, '').trim();
|
||||
const entities = JSON.parse(clean);
|
||||
console.log('[entities] Parsed entities:', entities);
|
||||
|
||||
if (!Array.isArray(entities)) throw new Error('Response was not a JSON array');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user