From a18dde36be0af00c2cebf08cdd2a8338ef711d9c Mon Sep 17 00:00:00 2001 From: Preston Rasmussen <109292228+prasmussen15@users.noreply.github.com> Date: Fri, 28 Feb 2025 17:06:25 -0500 Subject: [PATCH] Catch classification exceptions (#283) * Catch classification exceptions * except * Update graphiti_core/utils/maintenance/node_operations.py Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- .../utils/maintenance/node_operations.py | 18 +++++++++++------- pyproject.toml | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/graphiti_core/utils/maintenance/node_operations.py b/graphiti_core/utils/maintenance/node_operations.py index 425529d7..e0610433 100644 --- a/graphiti_core/utils/maintenance/node_operations.py +++ b/graphiti_core/utils/maintenance/node_operations.py @@ -158,13 +158,17 @@ async def extract_nodes( node_classifications: dict[str, str | None] = {} if entity_types is not None: - llm_response = await llm_client.generate_response( - prompt_library.extract_nodes.classify_nodes(node_classification_context), - response_model=EntityClassification, - ) - entities = llm_response.get('entities', []) - entity_classifications = llm_response.get('entity_classifications', []) - node_classifications.update(dict(zip(entities, entity_classifications))) + try: + llm_response = await llm_client.generate_response( + prompt_library.extract_nodes.classify_nodes(node_classification_context), + response_model=EntityClassification, + ) + entities = llm_response.get('entities', []) + entity_classifications = llm_response.get('entity_classifications', []) + node_classifications.update(dict(zip(entities, entity_classifications))) + # catch classification errors and continue if we can't classify + except Exception as e: + logger.exception(e) end = time() logger.debug(f'Extracted new nodes: {extracted_node_names} in {(end - start) * 1000} ms') diff --git a/pyproject.toml b/pyproject.toml index bbe09393..7b7f77b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "graphiti-core" -version = "0.7.5" +version = "0.7.6" description = "A temporal graph building library" authors = [ "Paul Paliychuk ",