chore: Format edge_operations.py and update lock file
- Minor formatting fix in edge_operations.py list comprehension - Update uv.lock with version bump to 0.21.0rc8 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
36356f491b
commit
34e69e6d36
3 changed files with 21 additions and 29 deletions
|
|
@ -23,23 +23,17 @@ from .prompt_helpers import to_prompt_json
|
||||||
|
|
||||||
|
|
||||||
class Edge(BaseModel):
|
class Edge(BaseModel):
|
||||||
relation_type: str = Field(
|
relation_type: str = Field(..., description='FACT_PREDICATE_IN_SCREAMING_SNAKE_CASE')
|
||||||
..., description="FACT_PREDICATE_IN_SCREAMING_SNAKE_CASE"
|
source_entity_id: int = Field(..., description='The id of the source entity of the fact.')
|
||||||
)
|
target_entity_id: int = Field(..., description='The id of the target entity of the fact.')
|
||||||
source_entity_id: int = Field(
|
fact: str = Field(..., description='')
|
||||||
..., description="The id of the source entity of the fact."
|
|
||||||
)
|
|
||||||
target_entity_id: int = Field(
|
|
||||||
..., description="The id of the target entity of the fact."
|
|
||||||
)
|
|
||||||
fact: str = Field(..., description="")
|
|
||||||
valid_at: str | None = Field(
|
valid_at: str | None = Field(
|
||||||
None,
|
None,
|
||||||
description="The date and time when the relationship described by the edge fact became true or was established. Use ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSSSSZ)",
|
description='The date and time when the relationship described by the edge fact became true or was established. Use ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSSSSZ)',
|
||||||
)
|
)
|
||||||
invalid_at: str | None = Field(
|
invalid_at: str | None = Field(
|
||||||
None,
|
None,
|
||||||
description="The date and time when the relationship described by the edge fact stopped being true or ended. Use ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSSSSZ)",
|
description='The date and time when the relationship described by the edge fact stopped being true or ended. Use ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSSSSZ)',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -66,13 +60,13 @@ class Versions(TypedDict):
|
||||||
def edge(context: dict[str, Any]) -> list[Message]:
|
def edge(context: dict[str, Any]) -> list[Message]:
|
||||||
return [
|
return [
|
||||||
Message(
|
Message(
|
||||||
role="system",
|
role='system',
|
||||||
content="You are an expert fact extractor that extracts fact triples from text. "
|
content='You are an expert fact extractor that extracts fact triples from text. '
|
||||||
"1. Extracted fact triples should also be extracted with relevant date information."
|
'1. Extracted fact triples should also be extracted with relevant date information.'
|
||||||
"2. Treat the CURRENT TIME as the time the CURRENT MESSAGE was sent. All temporal information should be extracted relative to this time.",
|
'2. Treat the CURRENT TIME as the time the CURRENT MESSAGE was sent. All temporal information should be extracted relative to this time.',
|
||||||
),
|
),
|
||||||
Message(
|
Message(
|
||||||
role="user",
|
role='user',
|
||||||
content=f"""
|
content=f"""
|
||||||
<FACT TYPES>
|
<FACT TYPES>
|
||||||
{context['edge_types']}
|
{context['edge_types']}
|
||||||
|
|
@ -157,19 +151,19 @@ Given the above MESSAGES, list of EXTRACTED ENTITIES entities, and list of EXTRA
|
||||||
determine if any facts haven't been extracted.
|
determine if any facts haven't been extracted.
|
||||||
"""
|
"""
|
||||||
return [
|
return [
|
||||||
Message(role="system", content=sys_prompt),
|
Message(role='system', content=sys_prompt),
|
||||||
Message(role="user", content=user_prompt),
|
Message(role='user', content=user_prompt),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def extract_attributes(context: dict[str, Any]) -> list[Message]:
|
def extract_attributes(context: dict[str, Any]) -> list[Message]:
|
||||||
return [
|
return [
|
||||||
Message(
|
Message(
|
||||||
role="system",
|
role='system',
|
||||||
content="You are a helpful assistant that extracts fact properties from the provided text.",
|
content='You are a helpful assistant that extracts fact properties from the provided text.',
|
||||||
),
|
),
|
||||||
Message(
|
Message(
|
||||||
role="user",
|
role='user',
|
||||||
content=f"""
|
content=f"""
|
||||||
|
|
||||||
<MESSAGE>
|
<MESSAGE>
|
||||||
|
|
@ -195,7 +189,7 @@ def extract_attributes(context: dict[str, Any]) -> list[Message]:
|
||||||
|
|
||||||
|
|
||||||
versions: Versions = {
|
versions: Versions = {
|
||||||
"edge": edge,
|
'edge': edge,
|
||||||
"reflexion": reflexion,
|
'reflexion': reflexion,
|
||||||
"extract_attributes": extract_attributes,
|
'extract_attributes': extract_attributes,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -480,9 +480,7 @@ async def resolve_extracted_edge(
|
||||||
start = time()
|
start = time()
|
||||||
|
|
||||||
# Prepare context for LLM
|
# Prepare context for LLM
|
||||||
related_edges_context = [
|
related_edges_context = [{'id': i, 'fact': edge.fact} for i, edge in enumerate(related_edges)]
|
||||||
{'id': i, 'fact': edge.fact} for i, edge in enumerate(related_edges)
|
|
||||||
]
|
|
||||||
|
|
||||||
invalidation_edge_candidates_context = [
|
invalidation_edge_candidates_context = [
|
||||||
{'id': i, 'fact': existing_edge.fact} for i, existing_edge in enumerate(existing_edges)
|
{'id': i, 'fact': existing_edge.fact} for i, existing_edge in enumerate(existing_edges)
|
||||||
|
|
|
||||||
2
uv.lock
generated
2
uv.lock
generated
|
|
@ -783,7 +783,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "graphiti-core"
|
name = "graphiti-core"
|
||||||
version = "0.21.0rc7"
|
version = "0.21.0rc8"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "diskcache" },
|
{ name = "diskcache" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue