diff --git a/lightrag/operate.py b/lightrag/operate.py index 74c8e5f6..a40af9e0 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -264,6 +264,16 @@ async def extract_entities( else: examples = "\n".join(PROMPTS["entity_extraction_examples"]) + example_context_base = dict( + tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"], + record_delimiter=PROMPTS["DEFAULT_RECORD_DELIMITER"], + completion_delimiter=PROMPTS["DEFAULT_COMPLETION_DELIMITER"], + entity_types=",".join(PROMPTS["DEFAULT_ENTITY_TYPES"]), + language=language, + ) + # add example's format + examples = examples.format(**example_context_base) + entity_extract_prompt = PROMPTS["entity_extraction"] context_base = dict( tuple_delimiter=PROMPTS["DEFAULT_TUPLE_DELIMITER"], diff --git a/lightrag/prompt.py b/lightrag/prompt.py index 5e71c081..d758397b 100644 --- a/lightrag/prompt.py +++ b/lightrag/prompt.py @@ -19,7 +19,7 @@ Use {language} as output language. - entity_name: Name of the entity, use same language as input text. If English, capitalized the name. - entity_type: One of the following types: [{entity_types}] - entity_description: Comprehensive description of the entity's attributes and activities -Format each entity as ("entity"{tuple_delimiter}{tuple_delimiter}{tuple_delimiter} +Format each entity as ("entity"{tuple_delimiter}{tuple_delimiter}{tuple_delimiter}) 2. From the entities identified in step 1, identify all pairs of (source_entity, target_entity) that are *clearly related* to each other. For each pair of related entities, extract the following information: