diff --git a/packages/memory-service/src/entities/extraction.js b/packages/memory-service/src/entities/extraction.js index e89d9bd..9a953ed 100644 --- a/packages/memory-service/src/entities/extraction.js +++ b/packages/memory-service/src/entities/extraction.js @@ -18,33 +18,21 @@ function buildExtractionPrompt(userMessage, aiResponse, knownEntities = []) { : ''; 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.', + '<|user|>', + 'Extract all named entities from this conversation as a JSON array. Output only valid JSON, nothing else.', '', `Valid types: ${ENTITY_TYPES.join(', ')}`, '', knownBlock, - '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:', + 'Each item must have:', ' "name": the entity name (match exactly if already known)', - ' "type": one of the valid types above (match exactly if already known)', + ' "type": one of the valid types above', ' "notes": one sentence describing this entity based on the conversation', '', - '### Conversation:', `User: ${userMessage}`, `Assistant: ${aiResponse}`, - '', - '### Extracted entities as JSON array:', - '<|im_end|>', - '<|im_start|>assistant', + '<|end|>', + '<|assistant|>', '[', ].join('\n'); }