graphiti/graphiti_core
Daniel Chalef 590282524a
fix: Improve edge extraction entity ID validation (#968)
* fix: Improve edge extraction entity ID validation

Fixes invalid entity ID references in edge extraction that caused warnings like:
"WARNING: source or target node not filled WILL_FIND. source_node_uuid: 23 and target_node_uuid: 3"

Changes:
- Format ENTITIES list as proper JSON in prompt for better LLM parsing
- Clarify field descriptions to reference entity id from ENTITIES list
- Add explicit entity ID validation as #1 extraction rule with examples
- Improve error logging (removed PII, added entity count and valid range)

These changes follow patterns from extract_nodes.py and dedupe_nodes.py where
entity referencing works reliably.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* wip

* fix: Align fact field naming and add description

- Change extraction rule to reference 'fact' instead of 'fact_text'
- Add descriptive text for fact field in Edge model

* fix: Remove ensure_ascii parameter from to_prompt_json call

Align with other to_prompt_json calls that don't use ensure_ascii

* fix: Use validated target_node_idx variable consistently

Line 190 was using raw edge_data.target_entity_id instead of the
validated target_node_idx variable, creating inconsistency with line 189

* fix: Improve edge extraction validation checks

- Add explicit check for empty nodes list
- Use more explicit 0 <= idx comparison instead of -1 < idx
- Prevents nonsensical error message when no entities provided

* chore: Restore uv.lock from main branch

Previously deleted in commit 7e4464b, now restored to match main branch state

* Update uv.lock

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-02 22:45:11 -07:00
..
cross_encoder fix typo and model selector (#843) 2025-08-18 11:15:45 -04:00
driver Graph quality updates (#922) 2025-09-23 17:53:39 -04:00
embedder OpenSearch Integration for Neo4j (#896) 2025-09-09 10:51:46 -04:00
llm_client Make natural language extraction configurable (#943) 2025-09-30 11:09:03 -04:00
migrations cleanup (#894) 2025-09-05 11:30:46 -04:00
models OpenSearch Integration for Neo4j (#896) 2025-09-09 10:51:46 -04:00
prompts fix: Improve edge extraction entity ID validation (#968) 2025-10-02 22:45:11 -07:00
search Remove ensure_ascii configuration parameter (#969) 2025-10-02 15:10:57 -07:00
telemetry feat: add telemetry with PostHog and update Docker configurations (#633) 2025-06-27 12:23:30 -07:00
utils fix: Improve edge extraction entity ID validation (#968) 2025-10-02 22:45:11 -07:00
__init__.py chore: Fix packaging (#38) 2024-08-25 10:07:50 -07:00
edges.py filter out falsey values before creating embeddings (#966) 2025-10-02 15:26:51 -04:00
errors.py Add group ID validation and error handling (#618) 2025-06-24 09:33:54 -07:00
graph_queries.py Graph quality updates (#922) 2025-09-23 17:53:39 -04:00
graphiti.py Remove ensure_ascii configuration parameter (#969) 2025-10-02 15:10:57 -07:00
graphiti_types.py Remove ensure_ascii configuration parameter (#969) 2025-10-02 15:10:57 -07:00
helpers.py fix-fulltext-syntax-error (#914) 2025-09-23 10:52:44 -04:00
nodes.py filter out falsey values before creating embeddings (#966) 2025-10-02 15:26:51 -04:00
py.typed Add py.typed file (#105) 2024-09-11 08:44:06 -04:00