extraction error logging
This commit is contained in:
@@ -3,7 +3,7 @@ const { getEnv, SERVICES, formatEpisodeText } = require('@nexusai/shared');
|
|||||||
const { upsertEntity } = require('./index');
|
const { upsertEntity } = require('./index');
|
||||||
|
|
||||||
const EXTRACTION_URL = getEnv('EXTRACTION_URL', 'http://localhost:11434');
|
const EXTRACTION_URL = getEnv('EXTRACTION_URL', 'http://localhost:11434');
|
||||||
const EXTRACTION_MODEL = getEnv('EXTRACTION_MODEL', 'qwen2.5:3b');
|
const EXTRACTION_MODEL = getEnv('EXTRACTION_MODEL', 'phi3:3.8ab');
|
||||||
const EMBEDDING_SERVICE_URL = getEnv('EMBEDDING_SERVICE_URL', SERVICES.EMBEDDING_URL);
|
const EMBEDDING_SERVICE_URL = getEnv('EMBEDDING_SERVICE_URL', SERVICES.EMBEDDING_URL);
|
||||||
|
|
||||||
const ENTITY_TYPES = ['person', 'place', 'project', 'technology', 'concept', 'organization'];
|
const ENTITY_TYPES = ['person', 'place', 'project', 'technology', 'concept', 'organization'];
|
||||||
@@ -68,7 +68,7 @@ async function extractAndStoreEntities(userMessage, aiResponse, projectId=null)
|
|||||||
stream: false,
|
stream: false,
|
||||||
options: {
|
options: {
|
||||||
temperature: 0.1,
|
temperature: 0.1,
|
||||||
num_predict: 512,
|
num_predict: 768,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@@ -77,10 +77,12 @@ async function extractAndStoreEntities(userMessage, aiResponse, projectId=null)
|
|||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const raw = data.response?.trim() ?? '';
|
const raw = data.response?.trim() ?? '';
|
||||||
console.log('[entities] raw response:', raw.slice(0, 300));
|
console.log('[entities] raw response:', JSON.stringify(raw.slice(0, 300)));
|
||||||
|
|
||||||
// Extract just the JSON array — everything from [ to the last ]
|
// Extract just the JSON array — everything from [ to the last ]
|
||||||
const match = raw.match(/\[[\s\S]*\]/);
|
const stripped = raw.replace(/```(?:json)?/g, '').trim();
|
||||||
|
const match = stripped.match(/\[[\s\S]*\]/);
|
||||||
|
|
||||||
if (!match) throw new Error('No JSON array found in response');
|
if (!match) throw new Error('No JSON array found in response');
|
||||||
const clean = match[0];
|
const clean = match[0];
|
||||||
const entities = JSON.parse(clean);
|
const entities = JSON.parse(clean);
|
||||||
|
|||||||
Reference in New Issue
Block a user