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>
This commit is contained in:
Preston Rasmussen 2025-02-28 17:06:25 -05:00 committed by GitHub
parent 6f874730f3
commit a18dde36be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -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')

View file

@ -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 <paul@getzep.com>",