diff --git a/cognee/shared/logging_utils.py b/cognee/shared/logging_utils.py index 83519f676..ecc22c737 100644 --- a/cognee/shared/logging_utils.py +++ b/cognee/shared/logging_utils.py @@ -264,7 +264,9 @@ def setup_logging(log_level=None, name=None): exc_info=(exc_type, exc_value, traceback), ) logger.info("Want to learn more? Visit the Cognee documentation: https://docs.cognee.ai") - logger.info("Need help? Reach out to us on our Discord server: https://discord.gg/NQPKmU5CCg") + logger.info( + "Need help? Reach out to us on our Discord server: https://discord.gg/NQPKmU5CCg" + ) # Install exception handlers sys.excepthook = handle_exception diff --git a/examples/python/relational_database_migration_example.py b/examples/python/relational_database_migration_example.py index c19e21435..fae8cfb3d 100644 --- a/examples/python/relational_database_migration_example.py +++ b/examples/python/relational_database_migration_example.py @@ -1,4 +1,5 @@ import asyncio + import cognee import os @@ -56,12 +57,8 @@ async def main(): home_dir = os.path.expanduser("~") destination_file_path = os.path.join(home_dir, "graph_visualization.html") - # test.html is a file with visualized data migration - print("Adding html visualization of graph database after migration.") - await visualize_graph(destination_file_path) - print(f"Visualization can be found at: {destination_file_path}") - # Make sure to set top_k at a high value for a broader search, the default value is only 10! + # top_k represent the number of graph tripplets to supply to the LLM to answer your question search_results = await cognee.search( query_type=SearchType.GRAPH_COMPLETION, query_text="What kind of data do you contain?", @@ -69,6 +66,20 @@ async def main(): ) print(f"Search results: {search_results}") + # Having a top_k value set to too high might overwhelm the LLM context when specific questions need to be answered. + # For this kind of question we've set the top_k to 30 + search_results = await cognee.search( + query_type=SearchType.GRAPH_COMPLETION_COT, + query_text="What invoices are related to Leonie Köhler?", + top_k=30, + ) + print(f"Search results: {search_results}") + + # test.html is a file with visualized data migration + print("Adding html visualization of graph database after migration.") + await visualize_graph(destination_file_path) + print(f"Visualization can be found at: {destination_file_path}") + if __name__ == "__main__": loop = asyncio.new_event_loop()