cognee/examples/python/graphiti_example.py
2025-01-05 19:09:08 +01:00

33 lines
857 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import asyncio
import cognee
from cognee.api.v1.search import SearchType
from cognee.modules.pipelines import Task, run_tasks
from cognee.tasks.temporal_awareness import (
build_graph_with_temporal_awareness,
search_graph_with_temporal_awareness,
)
text_list = [
"Kamala Harris is the Attorney General of California. She was previously "
"the district attorney for San Francisco.",
"As AG, Harris was in office from January 3, 2011 January 3, 2017",
]
async def main():
tasks = [
Task(build_graph_with_temporal_awareness, text_list=text_list),
Task(
search_graph_with_temporal_awareness, query="Who was the California Attorney General?"
),
]
pipeline = run_tasks(tasks)
async for result in pipeline:
print(result)
if __name__ == "__main__":
asyncio.run(main())