Skip to content

Commit

Permalink
make broader use of debug logs (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen15 authored Oct 11, 2024
1 parent f52b45b commit 6c3b32e
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 94 deletions.
10 changes: 5 additions & 5 deletions graphiti_core/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def delete(self, driver: AsyncDriver):
uuid=self.uuid,
)

logger.info(f'Deleted Edge: {self.uuid}')
logger.debug(f'Deleted Edge: {self.uuid}')

return result

Expand Down Expand Up @@ -83,7 +83,7 @@ async def save(self, driver: AsyncDriver):
created_at=self.created_at,
)

logger.info(f'Saved edge to neo4j: {self.uuid}')
logger.debug(f'Saved edge to neo4j: {self.uuid}')

return result

Expand Down Expand Up @@ -178,7 +178,7 @@ async def generate_embedding(self, embedder: EmbedderClient):
self.fact_embedding = await embedder.create(input=[text])

end = time()
logger.info(f'embedded {text} in {end - start} ms')
logger.debug(f'embedded {text} in {end - start} ms')

return self.fact_embedding

Expand Down Expand Up @@ -206,7 +206,7 @@ async def save(self, driver: AsyncDriver):
invalid_at=self.invalid_at,
)

logger.info(f'Saved edge to neo4j: {self.uuid}')
logger.debug(f'Saved edge to neo4j: {self.uuid}')

return result

Expand Down Expand Up @@ -313,7 +313,7 @@ async def save(self, driver: AsyncDriver):
created_at=self.created_at,
)

logger.info(f'Saved edge to neo4j: {self.uuid}')
logger.debug(f'Saved edge to neo4j: {self.uuid}')

return result

Expand Down
2 changes: 1 addition & 1 deletion graphiti_core/embedder/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, config: OpenAIEmbedderConfig | None = None):
self.client = AsyncOpenAI(api_key=config.api_key, base_url=config.base_url)

async def create(
self, input: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
self, input: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
) -> list[float]:
result = await self.client.embeddings.create(input=input, model=self.config.embedding_model)
return result.data[0].embedding[: self.config.embedding_dim]
2 changes: 1 addition & 1 deletion graphiti_core/embedder/voyage.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, config: VoyageAIEmbedderConfig | None = None):
self.client = voyageai.AsyncClient(api_key=config.api_key)

async def create(
self, input: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
self, input: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
) -> list[float]:
result = await self.client.embed(input, model=self.config.embedding_model)
return result.embeddings[0][: self.config.embedding_dim]
16 changes: 8 additions & 8 deletions graphiti_core/graphiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async def add_episode_endpoint(episode_data: EpisodeData):
# Extract entities as nodes

extracted_nodes = await extract_nodes(self.llm_client, episode, previous_episodes)
logger.info(f'Extracted nodes: {[(n.name, n.uuid) for n in extracted_nodes]}')
logger.debug(f'Extracted nodes: {[(n.name, n.uuid) for n in extracted_nodes]}')

# Calculate Embeddings

Expand All @@ -340,15 +340,15 @@ async def add_episode_endpoint(episode_data: EpisodeData):
)
)

logger.info(f'Extracted nodes: {[(n.name, n.uuid) for n in extracted_nodes]}')
logger.debug(f'Extracted nodes: {[(n.name, n.uuid) for n in extracted_nodes]}')

(mentioned_nodes, uuid_map), extracted_edges = await asyncio.gather(
resolve_extracted_nodes(self.llm_client, extracted_nodes, existing_nodes_lists),
extract_edges(
self.llm_client, episode, extracted_nodes, previous_episodes, group_id
),
)
logger.info(f'Adjusted mentioned nodes: {[(n.name, n.uuid) for n in mentioned_nodes]}')
logger.debug(f'Adjusted mentioned nodes: {[(n.name, n.uuid) for n in mentioned_nodes]}')
nodes = mentioned_nodes

extracted_edges_with_resolved_pointers = resolve_edge_pointers(
Expand Down Expand Up @@ -378,10 +378,10 @@ async def add_episode_endpoint(episode_data: EpisodeData):
]
)
)
logger.info(
logger.debug(
f'Related edges lists: {[(e.name, e.uuid) for edges_lst in related_edges_list for e in edges_lst]}'
)
logger.info(
logger.debug(
f'Extracted edges: {[(e.name, e.uuid) for e in extracted_edges_with_resolved_pointers]}'
)

Expand Down Expand Up @@ -433,11 +433,11 @@ async def add_episode_endpoint(episode_data: EpisodeData):

entity_edges.extend(resolved_edges + invalidated_edges)

logger.info(f'Resolved edges: {[(e.name, e.uuid) for e in resolved_edges]}')
logger.debug(f'Resolved edges: {[(e.name, e.uuid) for e in resolved_edges]}')

episodic_edges: list[EpisodicEdge] = build_episodic_edges(mentioned_nodes, episode, now)

logger.info(f'Built episodic edges: {episodic_edges}')
logger.debug(f'Built episodic edges: {episodic_edges}')

episode.entity_edges = [edge.uuid for edge in entity_edges]

Expand Down Expand Up @@ -563,7 +563,7 @@ async def add_episode_bulk(self, bulk_episodes: list[RawEpisode], group_id: str
edges = await dedupe_edges_bulk(
self.driver, self.llm_client, extracted_edges_with_resolved_pointers
)
logger.info(f'extracted edge length: {len(edges)}')
logger.debug(f'extracted edge length: {len(edges)}')

# invalidate edges

Expand Down
12 changes: 6 additions & 6 deletions graphiti_core/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def delete(self, driver: AsyncDriver):
uuid=self.uuid,
)

logger.info(f'Deleted Node: {self.uuid}')
logger.debug(f'Deleted Node: {self.uuid}')

return result

Expand Down Expand Up @@ -135,7 +135,7 @@ async def save(self, driver: AsyncDriver):
source=self.source.value,
)

logger.info(f'Saved Node to neo4j: {self.uuid}')
logger.debug(f'Saved Node to neo4j: {self.uuid}')

return result

Expand Down Expand Up @@ -217,7 +217,7 @@ async def generate_name_embedding(self, embedder: EmbedderClient):
text = self.name.replace('\n', ' ')
self.name_embedding = await embedder.create(input=[text])
end = time()
logger.info(f'embedded {text} in {end - start} ms')
logger.debug(f'embedded {text} in {end - start} ms')

return self.name_embedding

Expand All @@ -236,7 +236,7 @@ async def save(self, driver: AsyncDriver):
created_at=self.created_at,
)

logger.info(f'Saved Node to neo4j: {self.uuid}')
logger.debug(f'Saved Node to neo4j: {self.uuid}')

return result

Expand Down Expand Up @@ -320,7 +320,7 @@ async def save(self, driver: AsyncDriver):
created_at=self.created_at,
)

logger.info(f'Saved Node to neo4j: {self.uuid}')
logger.debug(f'Saved Node to neo4j: {self.uuid}')

return result

Expand All @@ -329,7 +329,7 @@ async def generate_name_embedding(self, embedder: EmbedderClient):
text = self.name.replace('\n', ' ')
self.name_embedding = await embedder.create(input=[text])
end = time()
logger.info(f'embedded {text} in {end - start} ms')
logger.debug(f'embedded {text} in {end - start} ms')

return self.name_embedding

Expand Down
Loading

0 comments on commit 6c3b32e

Please sign in to comment.