Fixes added

This commit is contained in:
vasilije 2025-04-15 12:21:59 +02:00
parent a142e27e39
commit 1c40a5081a
3 changed files with 38 additions and 90 deletions

View file

@ -1,67 +0,0 @@
# Cognee Configuration file
# Copy this file to .env and fill in the values
# Default User Configuration
DEFAULT_USER_EMAIL=""
DEFAULT_USER_PASSWORD=""
# Vector Database configuration
VECTOR_DB_TYPE=ChromaDB
VECTOR_DB_PATH=./chromadb
CHROMA_PERSIST_DIRECTORY=./chroma_db
# Graph Database configuration
GRAPH_DB_TYPE=NetworkX
GRAPH_DB_PATH=./.data/graph.json
# Content Storage configuration
CONTENT_STORAGE_TYPE=FileSystem
CONTENT_STORAGE_PATH=./storage
# Application settings
APP_NAME=Cognee
APP_ENVIRONMENT=production
LOG_LEVEL=INFO
# LLM configuration
LLM_PROVIDER=openai
LLM_MODEL=gpt-4
LLM_API_KEY=sk-...
LLM_ENDPOINT=
LLM_API_VERSION=
LLM_TEMPERATURE=0.0
LLM_STREAMING=false
LLM_MAX_TOKENS=16384
# Rate limiting configuration
LLM_RATE_LIMIT_ENABLED=false
LLM_RATE_LIMIT=60/minute
LLM_RATE_LIMIT_STRATEGY=moving-window
LLM_RATE_LIMIT_STORAGE=memory
# For Redis storage
# LLM_RATE_LIMIT_REDIS_URL=redis://localhost:6379/0
# For Memcached storage
# LLM_RATE_LIMIT_MEMCACHED_HOST=localhost
# LLM_RATE_LIMIT_MEMCACHED_PORT=11211
# Embedding configuration
EMBEDDING_PROVIDER=openai
EMBEDDING_MODEL=text-embedding-3-small
EMBEDDING_DIMENSIONS=1536
EMBEDDING_API_KEY=sk-...
# MongoDB configuration (optional)
# MONGODB_URI=mongodb://localhost:27017
# MONGODB_DB_NAME=cognee
# Metrics configuration (optional)
METRICS_ENABLED=false
METRICS_PORT=9090
# Monitoring configuration
MONITORING_TOOL=None
# For Langfuse (optional)
# LANGFUSE_HOST=https://cloud.langfuse.com
# LANGFUSE_PUBLIC_KEY=pk-...
# LANGFUSE_SECRET_KEY=sk-...
# LANGFUSE_PROJECT_ID=...

View file

@ -41,13 +41,13 @@ async def add_text_with_nodeset(text: str, node_set: List[str], text_id: str = N
text_id = str(uuid.uuid4())
# Print NodeSet details
logger.info(f"Adding text with NodeSet")
logger.info("Adding text with NodeSet")
logger.info(f"NodeSet for this text: {node_set}")
# Use high-level cognee.add() with the correct parameters
await cognee.add(text, node_set=node_set)
logger.info(f"Saved text with NodeSet to database")
logger.info("Saved text with NodeSet to database")
return text_id # Note: we can't control the actual ID generated by cognee.add()
@ -56,10 +56,11 @@ async def check_data_records():
db_engine = get_relational_engine()
async with db_engine.get_async_session() as session:
from sqlalchemy import select
query = select(Data)
result = await session.execute(query)
records = result.scalars().all()
logger.info(f"Found {len(records)} records in the database")
for record in records:
logger.info(f"Record ID: {record.id}, name: {record.name}, node_set: {record.node_set}")
@ -78,8 +79,12 @@ async def run_simple_node_set_test():
# Generate test node IDs for two NodeSets
# nodeset1 = await generate_test_node_ids(3)
nodeset2 = await generate_test_node_ids(3)
nodeset1 = ["test","horse", "mamamama"]
nodeset1 = [
"my_accounting_data",
"my_set_of_manuals_about_horses",
"my_elon_musk_secret_file",
]
logger.info(f"Created test node IDs for NodeSet 1: {nodeset1}")
logger.info(f"Created test node IDs for NodeSet 2: {nodeset2}")
@ -89,6 +94,8 @@ async def run_simple_node_set_test():
text1_id = await add_text_with_nodeset(text1, nodeset1)
text2_id = await add_text_with_nodeset(text2, nodeset2)
logger.info(str(text1_id))
logger.info(str(text2_id))
# Verify that the NodeSets were stored correctly
await check_data_records()
@ -96,40 +103,48 @@ async def run_simple_node_set_test():
# Run the cognify process to create a knowledge graph
pipeline_run_id = await cognee.cognify()
logger.info(f"Cognify process completed with pipeline run ID: {pipeline_run_id}")
# Skip graph search as the NetworkXAdapter doesn't support Cypher
logger.info("Skipping graph search as NetworkXAdapter doesn't support Cypher")
# Search for insights related to the added texts
search_query = "NLP and AI"
logger.info(f"Searching for insights with query: '{search_query}'")
search_results = await cognee.search(query_type=SearchType.INSIGHTS, query_text=search_query)
search_results = await cognee.search(
query_type=SearchType.INSIGHTS, query_text=search_query
)
# Extract NodeSet information from search results
logger.info(f"Found {len(search_results)} search results for '{search_query}':")
for i, result in enumerate(search_results):
logger.info(f"Result {i+1} text: {getattr(result, 'text', 'No text')}")
logger.info(f"Result {i + 1} text: {getattr(result, 'text', 'No text')}")
# Check for NodeSet and SetNodeId
node_set = getattr(result, "NodeSet", None)
set_node_id = getattr(result, "SetNodeId", None)
logger.info(f"Result {i+1} - NodeSet: {node_set}, SetNodeId: {set_node_id}")
logger.info(f"Result {i + 1} - NodeSet: {node_set}, SetNodeId: {set_node_id}")
# Check id and type
logger.info(f"Result {i+1} - ID: {getattr(result, 'id', 'No ID')}, Type: {getattr(result, 'type', 'No type')}")
logger.info(
f"Result {i + 1} - ID: {getattr(result, 'id', 'No ID')}, Type: {getattr(result, 'type', 'No type')}"
)
# Check if this is a document chunk and has is_part_of property
if hasattr(result, "is_part_of") and result.is_part_of:
logger.info(f"Result {i+1} is a document chunk with parent ID: {result.is_part_of.id}")
logger.info(
f"Result {i + 1} is a document chunk with parent ID: {result.is_part_of.id}"
)
# Check if the parent has a NodeSet
parent_has_nodeset = hasattr(result.is_part_of, "NodeSet") and result.is_part_of.NodeSet
parent_has_nodeset = (
hasattr(result.is_part_of, "NodeSet") and result.is_part_of.NodeSet
)
logger.info(f" Parent has NodeSet: {parent_has_nodeset}")
if parent_has_nodeset:
logger.info(f" Parent NodeSet: {result.is_part_of.NodeSet}")
# Print all attributes of the result to see what's available
logger.info(f"Result {i+1} - All attributes: {dir(result)}")
logger.info(f"Result {i + 1} - All attributes: {dir(result)}")
except Exception as e:
logger.error(f"Error in simple NodeSet test: {e}")
@ -143,4 +158,4 @@ if __name__ == "__main__":
try:
loop.run_until_complete(run_simple_node_set_test())
finally:
loop.run_until_complete(loop.shutdown_asyncgens())
loop.run_until_complete(loop.shutdown_asyncgens())

View file

@ -4,9 +4,9 @@ import json
import os
from cognee.infrastructure.files.storage import LocalStorage
from cognee.shared.logging_utils import get_logger
logger = logging.getLogger(__name__)
logger = get_logger()
async def cognee_network_visualization(graph_data, destination_file_path: str = None):