diff --git a/README.md b/README.md index 9fd5635ae..9407656a5 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ Now, run a minimal pipeline: ```python import cognee import asyncio +from pprint import pprint async def main(): @@ -143,7 +144,7 @@ async def main(): # Display the results for result in results: - print(result) + pprint(result) if __name__ == '__main__': diff --git a/examples/python/cognee_simple_document_demo.py b/examples/python/cognee_simple_document_demo.py index 26d63f969..4e73947ea 100644 --- a/examples/python/cognee_simple_document_demo.py +++ b/examples/python/cognee_simple_document_demo.py @@ -1,8 +1,9 @@ import asyncio import cognee - import os +from pprint import pprint + # By default cognee uses OpenAI's gpt-5-mini LLM model # Provide your OpenAI LLM API KEY os.environ["LLM_API_KEY"] = "" @@ -24,13 +25,13 @@ async def cognee_demo(): # Query Cognee for information from provided document answer = await cognee.search("List me all the important characters in Alice in Wonderland.") - print(answer) + pprint(answer) answer = await cognee.search("How did Alice end up in Wonderland?") - print(answer) + pprint(answer) answer = await cognee.search("Tell me about Alice's personality.") - print(answer) + pprint(answer) # Cognee is an async library, it has to be called in an async context diff --git a/examples/python/dynamic_steps_example.py b/examples/python/dynamic_steps_example.py index bce2ea8be..084406681 100644 --- a/examples/python/dynamic_steps_example.py +++ b/examples/python/dynamic_steps_example.py @@ -1,4 +1,5 @@ import asyncio +from pprint import pprint import cognee from cognee.api.v1.search import SearchType @@ -187,7 +188,7 @@ async def main(enable_steps): search_results = await cognee.search( query_type=SearchType.GRAPH_COMPLETION, query_text="Who has experience in design tools?" ) - print(search_results) + pprint(search_results) if __name__ == "__main__": diff --git a/examples/python/multimedia_example.py b/examples/python/multimedia_example.py index dd7260a15..453c5fb4d 100644 --- a/examples/python/multimedia_example.py +++ b/examples/python/multimedia_example.py @@ -1,6 +1,8 @@ import os import asyncio import pathlib +from pprint import pprint + from cognee.shared.logging_utils import setup_logging, ERROR import cognee @@ -42,7 +44,7 @@ async def main(): # Display search results for result_text in search_results: - print(result_text) + pprint(result_text) if __name__ == "__main__": diff --git a/examples/python/ontology_demo_example.py b/examples/python/ontology_demo_example.py index 5b18e6ed4..3d07178b3 100644 --- a/examples/python/ontology_demo_example.py +++ b/examples/python/ontology_demo_example.py @@ -1,5 +1,6 @@ import asyncio import os +from pprint import pprint import cognee from cognee.api.v1.search import SearchType @@ -77,7 +78,7 @@ async def main(): query_type=SearchType.GRAPH_COMPLETION, query_text="What are the exact cars and their types produced by Audi?", ) - print(search_results) + pprint(search_results) await visualize_graph() diff --git a/examples/python/permissions_example.py b/examples/python/permissions_example.py index c0b104023..0207ef50c 100644 --- a/examples/python/permissions_example.py +++ b/examples/python/permissions_example.py @@ -1,6 +1,7 @@ import os import cognee import pathlib +from pprint import pprint from cognee.modules.users.exceptions import PermissionDeniedError from cognee.modules.users.tenants.methods import select_tenant @@ -86,7 +87,7 @@ async def main(): ) print("\nSearch results as user_1 on dataset owned by user_1:") for result in search_results: - print(f"{result}\n") + pprint(result) # But user_1 cant read the dataset owned by user_2 (QUANTUM dataset) print("\nSearch result as user_1 on the dataset owned by user_2:") @@ -134,7 +135,7 @@ async def main(): dataset_ids=[quantum_dataset_id], ) for result in search_results: - print(f"{result}\n") + pprint(result) # If we'd like for user_1 to add new documents to the QUANTUM dataset owned by user_2, user_1 would have to get # "write" access permission, which user_1 currently does not have @@ -217,7 +218,7 @@ async def main(): dataset_ids=[quantum_cognee_lab_dataset_id], ) for result in search_results: - print(f"{result}\n") + pprint(result) # Note: All of these function calls and permission system is available through our backend endpoints as well diff --git a/examples/python/run_custom_pipeline_example.py b/examples/python/run_custom_pipeline_example.py index 1ca1b4402..6fae469cf 100644 --- a/examples/python/run_custom_pipeline_example.py +++ b/examples/python/run_custom_pipeline_example.py @@ -1,4 +1,6 @@ import asyncio +from pprint import pprint + import cognee from cognee.modules.engine.operations.setup import setup from cognee.modules.users.methods import get_default_user @@ -71,7 +73,7 @@ async def main(): print("Search results:") # Display results for result_text in search_results: - print(result_text) + pprint(result_text) if __name__ == "__main__": diff --git a/examples/python/simple_example.py b/examples/python/simple_example.py index 9d817561a..b98a5c0f1 100644 --- a/examples/python/simple_example.py +++ b/examples/python/simple_example.py @@ -1,4 +1,6 @@ import asyncio +from pprint import pprint + import cognee from cognee.shared.logging_utils import setup_logging, ERROR from cognee.api.v1.search import SearchType @@ -54,7 +56,7 @@ async def main(): print("Search results:") # Display results for result_text in search_results: - print(result_text) + pprint(result_text) if __name__ == "__main__": diff --git a/examples/python/temporal_example.py b/examples/python/temporal_example.py index f5e7d4a9a..48fc47542 100644 --- a/examples/python/temporal_example.py +++ b/examples/python/temporal_example.py @@ -1,4 +1,5 @@ import asyncio +from pprint import pprint import cognee from cognee.shared.logging_utils import setup_logging, INFO from cognee.api.v1.search import SearchType @@ -35,16 +36,16 @@ biography_1 = """ biography_2 = """ Arnulf Øverland Ole Peter Arnulf Øverland ( 27 April 1889 – 25 March 1968 ) was a Norwegian poet and artist . He is principally known for his poetry which served to inspire the Norwegian resistance movement during the German occupation of Norway during World War II . - + Biography . Øverland was born in Kristiansund and raised in Bergen . His parents were Peter Anton Øverland ( 1852–1906 ) and Hanna Hage ( 1854–1939 ) . The early death of his father , left the family economically stressed . He was able to attend Bergen Cathedral School and in 1904 Kristiania Cathedral School . He graduated in 1907 and for a time studied philology at University of Kristiania . Øverland published his first collection of poems ( 1911 ) . - + Øverland became a communist sympathizer from the early 1920s and became a member of Mot Dag . He also served as chairman of the Norwegian Students Society 1923–28 . He changed his stand in 1937 , partly as an expression of dissent against the ongoing Moscow Trials . He was an avid opponent of Nazism and in 1936 he wrote the poem Du må ikke sove which was printed in the journal Samtiden . It ends with . ( I thought: : Something is imminent . Our era is over – Europe’s on fire! ) . Probably the most famous line of the poem is ( You mustnt endure so well the injustice that doesnt affect you yourself! ) - + During the German occupation of Norway from 1940 in World War II , he wrote to inspire the Norwegian resistance movement . He wrote a series of poems which were clandestinely distributed , leading to the arrest of both him and his future wife Margrete Aamot Øverland in 1941 . Arnulf Øverland was held first in the prison camp of Grini before being transferred to Sachsenhausen concentration camp in Germany . He spent a four-year imprisonment until the liberation of Norway in 1945 . His poems were later collected in Vi overlever alt and published in 1945 . - + Øverland played an important role in the Norwegian language struggle in the post-war era . He became a noted supporter for the conservative written form of Norwegian called Riksmål , he was president of Riksmålsforbundet ( an organization in support of Riksmål ) from 1947 to 1956 . In addition , Øverland adhered to the traditionalist style of writing , criticising modernist poetry on several occasions . His speech Tungetale fra parnasset , published in Arbeiderbladet in 1954 , initiated the so-called Glossolalia debate . - + Personal life . In 1918 he had married the singer Hildur Arntzen ( 1888–1957 ) . Their marriage was dissolved in 1939 . In 1940 , he married Bartholine Eufemia Leganger ( 1903–1995 ) . They separated shortly after , and were officially divorced in 1945 . Øverland was married to journalist Margrete Aamot Øverland ( 1913–1978 ) during June 1945 . In 1946 , the Norwegian Parliament arranged for Arnulf and Margrete Aamot Øverland to reside at the Grotten . He lived there until his death in 1968 and she lived there for another ten years until her death in 1978 . Arnulf Øverland was buried at Vår Frelsers Gravlund in Oslo . Joseph Grimeland designed the bust of Arnulf Øverland ( bronze , 1970 ) at his grave site . @@ -56,7 +57,7 @@ biography_2 = """ - Vi overlever alt ( 1945 ) - Sverdet bak døren ( 1956 ) - Livets minutter ( 1965 ) - + Awards . - Gyldendals Endowment ( 1935 ) - Dobloug Prize ( 1951 ) @@ -87,7 +88,8 @@ async def main(): top_k=15, ) print(f"Query: {query_text}") - print(f"Results: {search_results}\n") + print("Results:") + pprint(search_results) if __name__ == "__main__": diff --git a/examples/python/triplet_embeddings_example.py b/examples/python/triplet_embeddings_example.py index dad8e8d12..1206c4331 100644 --- a/examples/python/triplet_embeddings_example.py +++ b/examples/python/triplet_embeddings_example.py @@ -1,4 +1,5 @@ import asyncio +from pprint import pprint import cognee from cognee.memify_pipelines.create_triplet_embeddings import create_triplet_embeddings @@ -65,7 +66,7 @@ async def main(): query_type=SearchType.TRIPLET_COMPLETION, query_text="What are the models produced by Volkswagen based on the context?", ) - print(search_results) + pprint(search_results) if __name__ == "__main__":