Files
wehub-resource-sync c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:02:24 +08:00

63 lines
1.9 KiB
Python

import asyncio
import os
import time
from pathlib import Path
from typing import Any, Awaitable, Callable, Optional
import cognee
from cognee import visualize_graph
from examples.pocs.post_extraction_canonicalization.post_extraction_canonicalization import (
post_extraction_canonicalization,
)
async def main(
example,
post_extraction_canonicalization_fun: (
Callable[[str, int, bool, str | None], Awaitable[Any]] | None
) = None,
custom_prompt: Optional[str] = None,
):
await cognee.prune.prune_data()
await cognee.prune.prune_system(metadata=True)
graph_visualization_path = os.path.join(
os.path.dirname(__file__),
f"results/{'poc_' if post_extraction_canonicalization_fun else ''}cognify_disambiguate_{example}_result.html",
)
parts_dir = Path(__file__).resolve().parent / "data" / example
if post_extraction_canonicalization_fun:
await post_extraction_canonicalization_fun(parts_dir, custom_prompt)
else:
start = time.perf_counter()
for part in sorted(parts_dir.glob("part_*.txt")):
print(part)
text = part.read_text(encoding="utf-8").replace("\n", " ")
await cognee.add(text)
await cognee.cognify(chunk_size=1024, custom_prompt=custom_prompt)
elapsed = time.perf_counter() - start
print(f"Elapsed: {elapsed:.6f} seconds")
await visualize_graph(graph_visualization_path)
async def _run():
prompt_path = os.path.join(Path(__file__).resolve().parent, "prompts", "prompt2.txt")
with open(prompt_path, "r", encoding="utf-8") as f:
custom_prompt_text = f.read()
await main(
example="example2",
post_extraction_canonicalization_fun=post_extraction_canonicalization,
custom_prompt=custom_prompt_text,
)
# await main(
# example="example1",
# )
if __name__ == "__main__":
asyncio.run(_run())