diff --git a/cognee-frontend/src/app/globals.css b/cognee-frontend/src/app/globals.css index 59f8356f3..7179f07b6 100644 --- a/cognee-frontend/src/app/globals.css +++ b/cognee-frontend/src/app/globals.css @@ -6,6 +6,7 @@ "Fira Mono", "Droid Sans Mono", "Courier New", monospace; --global-background-default: #0D051C; + --textarea-default-color: #0D051C !important; } * { diff --git a/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx b/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx index 899cf70ae..21100cbf2 100644 --- a/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx +++ b/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx @@ -1,8 +1,7 @@ -import { useCallback, useEffect } from 'react'; -import { CTAButton, Spacer, Stack, Text, useBoolean } from 'ohmy-ui'; +import { useEffect, useRef } from 'react'; +import { CTAButton, Stack, Text, useBoolean } from 'ohmy-ui'; import { Divider } from '@/ui/Layout'; -import { CognifyLoadingIndicator, LoadingIndicator } from '@/ui/App'; -import { getExplorationGraphUrl } from '@/modules/exploration'; +import { CognifyLoadingIndicator } from '@/ui/App'; import { WizardHeading } from '@/ui/Partials/Wizard'; import cognifyDataset from '@/modules/datasets/cognifyDataset'; @@ -16,9 +15,14 @@ export default function CognifyStep({ onNext, dataset }: ConfigStepProps) { value: isCognifyRunning, setFalse: stopCognifyIndicator, } = useBoolean(true); + const cognifyPromise = useRef>() useEffect(() => { - cognifyDataset(dataset) + if (cognifyPromise.current) { + return; + } + + cognifyPromise.current = cognifyDataset(dataset) .then(() => { stopCognifyIndicator(); }); diff --git a/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts b/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts index 828c5a736..aa83b1520 100644 --- a/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts +++ b/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts @@ -1,5 +1,11 @@ export default function getExplorationGraphUrl(dataset: { id: string }) { return fetch(`http://0.0.0.0:8000/datasets/${dataset.id}/graph`) + .then(async (response) => { + if (response.status !== 200) { + throw new Error((await response.text()).replaceAll("\"", "")); + } + return response; + }) .then((response) => response.text()) .then((text) => text.replace('"', '')); } diff --git a/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx b/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx index 51bfecae1..ea50a726a 100644 --- a/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx +++ b/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useState } from 'react'; import classNames from 'classnames'; -import { Spacer, Stack } from 'ohmy-ui'; +import { Spacer, Stack, Text } from 'ohmy-ui'; import { getExplorationGraphUrl } from '@/modules/exploration'; import { IFrameView, SearchView } from '@/ui/Partials'; import { LoadingIndicator } from '@/ui/App'; @@ -13,12 +13,17 @@ interface ExplorerProps { } export default function Explorer({ dataset, className, style }: ExplorerProps) { + const [error, setError] = useState(null); const [graphUrl, setGraphUrl] = useState(null); const exploreData = useCallback(() => { getExplorationGraphUrl(dataset) .then((graphUrl) => { + setError(null); setGraphUrl(graphUrl); + }) + .catch((error) => { + setError(error); }); }, [dataset]); @@ -34,12 +39,18 @@ export default function Explorer({ dataset, className, style }: ExplorerProps) { className={classNames(styles.explorerContent, className)} >
- {!graphUrl ? ( - - - + {error ? ( + {error.message} ) : ( - + <> + {!graphUrl ? ( + + + + ) : ( + + )} + )}
diff --git a/cognee/api/client.py b/cognee/api/client.py index 6e2aa86e1..94fb259be 100644 --- a/cognee/api/client.py +++ b/cognee/api/client.py @@ -69,12 +69,9 @@ async def delete_dataset(dataset_id: str): @app.get("/datasets/{dataset_id}/graph", response_model=list) async def get_dataset_graph(dataset_id: str): from cognee.shared.utils import render_graph - from cognee.infrastructure.databases.graph import get_graph_config from cognee.infrastructure.databases.graph.get_graph_client import get_graph_client try: - # graph_config = get_graph_config() - # graph_engine = graph_config.graph_engine graph_client = await get_graph_client() graph_url = await render_graph(graph_client.graph) @@ -261,6 +258,7 @@ def start_api_server(host: str = "0.0.0.0", port: int = 8000): from cognee.base_config import get_base_config from cognee.infrastructure.databases.relational import get_relationaldb_config from cognee.infrastructure.databases.vector import get_vectordb_config + from cognee.infrastructure.databases.graph import get_graph_config cognee_directory_path = os.path.abspath(".cognee_system") databases_directory_path = os.path.join(cognee_directory_path, "databases") @@ -272,6 +270,9 @@ def start_api_server(host: str = "0.0.0.0", port: int = 8000): vector_config = get_vectordb_config() vector_config.vector_db_url = os.path.join(databases_directory_path, "cognee.lancedb") + graph_config = get_graph_config() + graph_config.graph_file_path = os.path.join(databases_directory_path, "cognee.graph") + base_config = get_base_config() data_directory_path = os.path.abspath(".data_storage") base_config.data_root_directory = data_directory_path diff --git a/cognee/infrastructure/databases/graph/config.py b/cognee/infrastructure/databases/graph/config.py index 9baea6d24..d20d997eb 100644 --- a/cognee/infrastructure/databases/graph/config.py +++ b/cognee/infrastructure/databases/graph/config.py @@ -3,8 +3,8 @@ import os from functools import lru_cache from pydantic_settings import BaseSettings, SettingsConfigDict -from cognee.infrastructure.databases.relational.config import get_relationaldb_config -from cognee.shared.data_models import GraphDBType, KnowledgeGraph +from cognee.shared.data_models import KnowledgeGraph +from cognee.root_dir import get_absolute_path class GraphConfig(BaseSettings): @@ -15,15 +15,16 @@ class GraphConfig(BaseSettings): graph_database_password: str = "" graph_database_port: int = 123 graph_file_path: str = os.path.join( - get_relationaldb_config().db_path, graph_filename + os.path.join(get_absolute_path(".cognee_system"), "databases"), + graph_filename ) - # graph_engine: object = GraphDBType.NETWORKX graph_model: object = KnowledgeGraph graph_topology_task: bool = False graph_topology: object = KnowledgeGraph infer_graph_topology: bool = True topology_file_path: str = os.path.join( - get_relationaldb_config().db_path, "graph_topology.json" + os.path.join(get_absolute_path(".cognee_system"), "databases"), + "graph_topology.json" ) model_config = SettingsConfigDict(env_file=".env", extra="allow") @@ -37,7 +38,6 @@ class GraphConfig(BaseSettings): "graph_database_username": self.graph_database_username, "graph_database_password": self.graph_database_password, "graph_database_port": self.graph_database_port, - # "graph_engine": self.graph_engine, "infer_graph_topology": self.infer_graph_topology, }