From cb7b2d311e21f21f320d811198bff769f47c1730 Mon Sep 17 00:00:00 2001 From: vasilije Date: Thu, 16 Jan 2025 21:36:25 +0100 Subject: [PATCH] Fix for now --- cognee-mcp/cognee_mcp/server.py | 4 +--- cognee-mcp/uv.lock | 6 ++++-- cognee/api/v1/visualize/visualize.py | 1 + cognee/shared/utils.py | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cognee-mcp/cognee_mcp/server.py b/cognee-mcp/cognee_mcp/server.py index 087411fa5..6ae93934e 100644 --- a/cognee-mcp/cognee_mcp/server.py +++ b/cognee-mcp/cognee_mcp/server.py @@ -200,9 +200,7 @@ async def handle_call_tool( with open(os.devnull, "w") as fnull: with redirect_stdout(fnull), redirect_stderr(fnull): try: - result = await cognee.visualize_graph() - results = retrieved_edges_to_string(result) - + results = await cognee.visualize_graph() return [ types.TextContent( type="text", diff --git a/cognee-mcp/uv.lock b/cognee-mcp/uv.lock index 63b23a11e..503a1ba82 100644 --- a/cognee-mcp/uv.lock +++ b/cognee-mcp/uv.lock @@ -597,6 +597,7 @@ dependencies = [ { name = "matplotlib" }, { name = "nest-asyncio" }, { name = "networkx" }, + { name = "nltk" }, { name = "numpy" }, { name = "openai" }, { name = "pandas" }, @@ -646,11 +647,12 @@ requires-dist = [ { name = "langfuse", specifier = ">=2.32.0,<3.0.0" }, { name = "langsmith", marker = "extra == 'langchain'", specifier = "==0.2.3" }, { name = "litellm", specifier = "==1.57.2" }, - { name = "llama-index-core", marker = "extra == 'llama-index'", specifier = ">=0.12.10.post1,<0.13.0" }, + { name = "llama-index-core", marker = "extra == 'llama-index'", specifier = ">=0.12.11,<0.13.0" }, { name = "matplotlib", specifier = ">=3.8.3,<4.0.0" }, { name = "neo4j", marker = "extra == 'neo4j'", specifier = ">=5.20.0,<6.0.0" }, { name = "nest-asyncio", specifier = "==1.6.0" }, { name = "networkx", specifier = ">=3.2.1,<4.0.0" }, + { name = "nltk", specifier = "==3.9.1" }, { name = "numpy", specifier = "==1.26.4" }, { name = "openai", specifier = "==1.59.4" }, { name = "pandas", specifier = "==2.2.3" }, @@ -672,7 +674,7 @@ requires-dist = [ { name = "tiktoken", specifier = "==0.7.0" }, { name = "transformers", specifier = ">=4.46.3,<5.0.0" }, { name = "typing-extensions", specifier = "==4.12.2" }, - { name = "unstructured", extras = ["csv", "doc", "docx", "epub", "md", "odt", "org", "ppt", "pptx", "rst", "rtf", "tsv", "xlsx"], marker = "extra == 'docs'", specifier = ">=0.16.10,<0.17.0" }, + { name = "unstructured", extras = ["csv", "doc", "docx", "epub", "md", "odt", "org", "ppt", "pptx", "rst", "rtf", "tsv", "xlsx"], marker = "extra == 'docs'", specifier = ">=0.16.13,<0.17.0" }, { name = "uvicorn", specifier = "==0.22.0" }, { name = "weaviate-client", marker = "extra == 'weaviate'", specifier = "==4.9.6" }, ] diff --git a/cognee/api/v1/visualize/visualize.py b/cognee/api/v1/visualize/visualize.py index 3267f9d3d..4c4c613c8 100644 --- a/cognee/api/v1/visualize/visualize.py +++ b/cognee/api/v1/visualize/visualize.py @@ -10,5 +10,6 @@ async def visualize_graph(label: str = "name"): logging.info(graph_data) graph = await create_cognee_style_network_with_logo(graph_data, label=label) + logging.info("The HTML file has been stored on your home directory! Navigate there with cd ~") return graph diff --git a/cognee/shared/utils.py b/cognee/shared/utils.py index f1eae1ace..f11b77ae6 100644 --- a/cognee/shared/utils.py +++ b/cognee/shared/utils.py @@ -444,7 +444,12 @@ async def create_cognee_style_network_with_logo( logging.info(f"Saving visualization to {output_filename}...") html_content = file_html(p, CDN, title) - with open(output_filename, "w") as f: + + home_dir = os.path.expanduser('~') + + # Construct the final output file path + output_filepath = os.path.join(home_dir, output_filename) + with open(output_filepath, "w") as f: f.write(html_content) return html_content