adding in entity extraction layer

This commit is contained in:
Storme-bit
2026-04-17 05:54:33 -07:00
parent 4070eb5559
commit 0cad85d4a7

View File

@@ -8,16 +8,33 @@ const ENTITY_TYPES = ['person', 'place', 'project', 'technology', 'concept', 'or
function buildExtractionPrompt(userMessage, aiResponse) {
return [
'Extract named entities from the conversation below.',
`Valid entity types: ${ENTITY_TYPES.join(', ')}.`,
'Return ONLY a JSON array. No explanation, no markdown, no code fences.',
'Each item must have exactly these fields: "name" (string), "type" (one of the valid types), "notes" (one sentence fact about this entity from the conversation).',
'If no entities are found, return: []',
'<|im_start|>system',
'You are an entity extraction assistant. You extract named entities from conversations and return them as a JSON array. You never return empty arrays when entities are present. You only output valid JSON.<|im_end|>',
'<|im_start|>user',
'Extract all named entities from this conversation.',
'',
`Valid types: ${ENTITY_TYPES.join(', ')}`,
'',
'Examples of entities to extract:',
'- People: names of individuals',
'- Projects: software projects, systems, tools being built',
'- Technologies: databases, frameworks, languages, hardware',
'- Organizations: companies, teams',
'- Places: locations, servers, infrastructure',
'',
'Return a JSON array where each item has:',
' "name": the entity name',
' "type": one of the valid types above',
' "notes": one sentence describing this entity based on the conversation',
'',
'### Conversation:',
`User: ${userMessage}`,
`Assistant: ${aiResponse}`,
'',
'JSON array:',
'### Extracted entities as JSON array:',
'<|im_end|>',
'<|im_start|>assistant',
'[',
].join('\n');
}