refactor: Update rel db example (#985)
<!-- .github/pull_request_template.md --> ## Description Update rel db example with better info ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --------- Co-authored-by: Boris Arzentar <borisarzentar@gmail.com>
This commit is contained in:
parent
82d388d211
commit
4936e1ea3d
2 changed files with 19 additions and 6 deletions
|
|
@ -264,7 +264,9 @@ def setup_logging(log_level=None, name=None):
|
||||||
exc_info=(exc_type, exc_value, traceback),
|
exc_info=(exc_type, exc_value, traceback),
|
||||||
)
|
)
|
||||||
logger.info("Want to learn more? Visit the Cognee documentation: https://docs.cognee.ai")
|
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
|
# Install exception handlers
|
||||||
sys.excepthook = handle_exception
|
sys.excepthook = handle_exception
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import cognee
|
import cognee
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
@ -56,12 +57,8 @@ async def main():
|
||||||
home_dir = os.path.expanduser("~")
|
home_dir = os.path.expanduser("~")
|
||||||
destination_file_path = os.path.join(home_dir, "graph_visualization.html")
|
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!
|
# 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(
|
search_results = await cognee.search(
|
||||||
query_type=SearchType.GRAPH_COMPLETION,
|
query_type=SearchType.GRAPH_COMPLETION,
|
||||||
query_text="What kind of data do you contain?",
|
query_text="What kind of data do you contain?",
|
||||||
|
|
@ -69,6 +66,20 @@ async def main():
|
||||||
)
|
)
|
||||||
print(f"Search results: {search_results}")
|
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__":
|
if __name__ == "__main__":
|
||||||
loop = asyncio.new_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue