bump version to 0.30.0pre5 and enhance docstring for resolve_extracted_edge function
- Update version in pyproject.toml to 0.30.0pre5. - Add detailed docstring to resolve_extracted_edge function in edge_operations.py, clarifying parameters and return values. This update improves documentation clarity for the edge resolution process.
This commit is contained in:
parent
46771eb90b
commit
f61f2329e0
2 changed files with 36 additions and 4 deletions
|
|
@ -417,6 +417,34 @@ async def resolve_extracted_edge(
|
||||||
custom_edge_type_names: set[str] | None = None,
|
custom_edge_type_names: set[str] | None = None,
|
||||||
ensure_ascii: bool = True,
|
ensure_ascii: bool = True,
|
||||||
) -> tuple[EntityEdge, list[EntityEdge], list[EntityEdge]]:
|
) -> tuple[EntityEdge, list[EntityEdge], list[EntityEdge]]:
|
||||||
|
"""Resolve an extracted edge against existing graph context.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
llm_client : LLMClient
|
||||||
|
Client used to invoke the LLM for deduplication and attribute extraction.
|
||||||
|
extracted_edge : EntityEdge
|
||||||
|
Newly extracted edge whose canonical representation is being resolved.
|
||||||
|
related_edges : list[EntityEdge]
|
||||||
|
Candidate edges with identical endpoints used for duplicate detection.
|
||||||
|
existing_edges : list[EntityEdge]
|
||||||
|
Broader set of edges evaluated for contradiction / invalidation.
|
||||||
|
episode : EpisodicNode
|
||||||
|
Episode providing content context when extracting edge attributes.
|
||||||
|
edge_type_candidates : dict[str, type[BaseModel]] | None
|
||||||
|
Custom edge types permitted for the current source/target signature.
|
||||||
|
custom_edge_type_names : set[str] | None
|
||||||
|
Full catalog of registered custom edge names. Used to distinguish
|
||||||
|
between disallowed custom types (which fall back to the default label)
|
||||||
|
and ad-hoc labels emitted by the LLM.
|
||||||
|
ensure_ascii : bool
|
||||||
|
Whether prompt payloads should coerce ASCII output.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
tuple[EntityEdge, list[EntityEdge], list[EntityEdge]]
|
||||||
|
The resolved edge, any duplicates, and edges to invalidate.
|
||||||
|
"""
|
||||||
if len(related_edges) == 0 and len(existing_edges) == 0:
|
if len(related_edges) == 0 and len(existing_edges) == 0:
|
||||||
return extracted_edge, [], []
|
return extracted_edge, [], []
|
||||||
|
|
||||||
|
|
@ -493,7 +521,11 @@ async def resolve_extracted_edge(
|
||||||
candidate_type_names = set(edge_type_candidates or {})
|
candidate_type_names = set(edge_type_candidates or {})
|
||||||
custom_type_names = custom_edge_type_names or set()
|
custom_type_names = custom_edge_type_names or set()
|
||||||
|
|
||||||
if candidate_type_names and fact_type in candidate_type_names:
|
is_default_type = fact_type.upper() == 'DEFAULT'
|
||||||
|
is_custom_type = fact_type in custom_type_names
|
||||||
|
is_allowed_custom_type = fact_type in candidate_type_names
|
||||||
|
|
||||||
|
if is_allowed_custom_type:
|
||||||
# The LLM selected a custom type that is allowed for the node pair.
|
# The LLM selected a custom type that is allowed for the node pair.
|
||||||
# Adopt the custom type and, if needed, extract its structured attributes.
|
# Adopt the custom type and, if needed, extract its structured attributes.
|
||||||
resolved_edge.name = fact_type
|
resolved_edge.name = fact_type
|
||||||
|
|
@ -514,12 +546,12 @@ async def resolve_extracted_edge(
|
||||||
)
|
)
|
||||||
|
|
||||||
resolved_edge.attributes = edge_attributes_response
|
resolved_edge.attributes = edge_attributes_response
|
||||||
elif fact_type.upper() != 'DEFAULT' and fact_type in custom_type_names:
|
elif not is_default_type and is_custom_type:
|
||||||
# The LLM picked a custom type that is not allowed for this signature.
|
# The LLM picked a custom type that is not allowed for this signature.
|
||||||
# Reset to the default label and drop any structured attributes.
|
# Reset to the default label and drop any structured attributes.
|
||||||
resolved_edge.name = DEFAULT_EDGE_NAME
|
resolved_edge.name = DEFAULT_EDGE_NAME
|
||||||
resolved_edge.attributes = {}
|
resolved_edge.attributes = {}
|
||||||
elif fact_type.upper() != 'DEFAULT':
|
elif not is_default_type:
|
||||||
# Non-custom labels are allowed to pass through so long as the LLM does
|
# Non-custom labels are allowed to pass through so long as the LLM does
|
||||||
# not return the sentinel DEFAULT value.
|
# not return the sentinel DEFAULT value.
|
||||||
resolved_edge.name = fact_type
|
resolved_edge.name = fact_type
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[project]
|
[project]
|
||||||
name = "graphiti-core"
|
name = "graphiti-core"
|
||||||
description = "A temporal graph building library"
|
description = "A temporal graph building library"
|
||||||
version = "0.30.0pre4"
|
version = "0.30.0pre5"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Paul Paliychuk", email = "paul@getzep.com" },
|
{ name = "Paul Paliychuk", email = "paul@getzep.com" },
|
||||||
{ name = "Preston Rasmussen", email = "preston@getzep.com" },
|
{ name = "Preston Rasmussen", email = "preston@getzep.com" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue