Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,4 @@ SWE-bench_testsample/

# ChromaDB Data
.chromadb_data/
.venvsource/
40 changes: 36 additions & 4 deletions cognee/api/v1/cognify/cognify.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from cognee.modules.users.models import User

from cognee.tasks.documents import (
check_permissions_on_dataset,
classify_documents,
extract_chunks_from_documents,
)

from cognee.tasks.graph import extract_graph_from_data
from cognee.tasks.storage import add_data_points
from cognee.tasks.summarization import summarize_text
Expand Down Expand Up @@ -69,7 +69,41 @@ async def cognify(

Input Requirements:
- **Datasets**: Must contain data previously added via `cognee.add()`
- **Content Types**: Works with any text-extractable content including:
import asyncio
from pydantic import BaseModel
from typing import Union, Optional
from uuid import UUID

from cognee.modules.ontology.ontology_env_config import get_ontology_env_co>
from cognee.shared.logging_utils import get_logger
from cognee.shared.data_models import KnowledgeGraph
from cognee.infrastructure.llm import get_max_chunk_tokens

from cognee.modules.pipelines import run_pipeline
from cognee.modules.pipelines.tasks.task import Task
from cognee.modules.chunking.TextChunker import TextChunker
from cognee.modules.ontology.ontology_config import Config
from cognee.modules.ontology.get_default_ontology_resolver import (
get_default_ontology_resolver,
get_ontology_resolver_from_env,
)
from cognee.modules.users.models import User

from cognee.tasks.documents import (
classify_documents,
extract_chunks_from_documents,
)
from cognee.tasks.graph import extract_graph_from_data
from cognee.tasks.storage import add_data_points
from cognee.tasks.summarization import summarize_text
from cognee.modules.pipelines.layers.pipeline_execution_mode import get_pip>
from cognee.tasks.temporal_graph.extract_events_and_entities import extract>
from cognee.tasks.temporal_graph.extract_knowledge_graph_from_events import>
extract_knowledge_graph_from_events,
)


logger = get_logger("cognify") - **Content Types**: Works with any text-extractable content including:
* Natural language documents
* Structured data (CSV, JSON)
* Code repositories
Expand Down Expand Up @@ -274,7 +308,6 @@ async def get_default_tasks( # TODO: Find out a better way to do this (Boris's

default_tasks = [
Task(classify_documents),
Task(check_permissions_on_dataset, user=user, permissions=["write"]),
Task(
extract_chunks_from_documents,
max_chunk_size=chunk_size or get_max_chunk_tokens(),
Expand Down Expand Up @@ -325,7 +358,6 @@ async def get_temporal_tasks(

temporal_tasks = [
Task(classify_documents),
Task(check_permissions_on_dataset, user=user, permissions=["write"]),
Task(
extract_chunks_from_documents,
max_chunk_size=chunk_size or get_max_chunk_tokens(),
Expand Down
47 changes: 47 additions & 0 deletions cognee/cli/minimal_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def get_command_info() -> dict:
"cognify": "Transform ingested data into a structured knowledge graph",
"delete": "Delete data from cognee knowledge base",
"config": "Manage cognee configuration settings",
"tui": "Launch a lightweight terminal UI for common Cognee tasks",
}



def print_help() -> None:
"""Print help message with dynamic command descriptions"""
commands = get_command_info()
Expand All @@ -68,6 +70,46 @@ def print_help() -> None:
For more information on each command, use: cognee <command> --help
""")

def run_tui() -> int:
"""Basic text-based TUI for common cognee commands."""
from cognee.cli._cognee import main as full_main

while True:
print("\nCognee TUI")
print("----------")
print("1) Add data")
print("2) Search knowledge graph")
print("3) Cognify data")
print("4) Delete data")
print("q) Quit")

choice = input("\nSelect an option: ").strip().lower()

if choice == "q":
print("Exiting Cognee TUI.")
return 0

cmd_map = {
"1": ["cognee", "add"],
"2": ["cognee", "search"],
"3": ["cognee", "cognify"],
"4": ["cognee", "delete"],
}

if choice not in cmd_map:
print("Invalid choice, please try again.")
continue

# Temporarily override sys.argv to reuse the existing CLI
original_argv = sys.argv
try:
sys.argv = cmd_map[choice]
full_main()
except Exception as e:
print(f"Error while running command: {e}")
finally:
sys.argv = original_argv


def main() -> int:
"""Minimal CLI main function"""
Expand All @@ -80,6 +122,10 @@ def main() -> int:
print(f"cognee {get_version()}")
return 0

# Handle lightweight TUI without changing the existing CLI behaviour
if len(sys.argv) >= 2 and sys.argv[1] == "tui":
return run_tui()

# For actual commands, import the full CLI with minimal logging
try:
from cognee.cli._cognee import main as full_main
Expand All @@ -93,5 +139,6 @@ def main() -> int:
return 1



if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from cognee.shared.data_models import KnowledgeGraph
from cognee.shared.utils import send_telemetry
from cognee.tasks.documents import (
check_permissions_on_dataset,
classify_documents,
extract_chunks_from_documents,
)
Expand All @@ -31,7 +30,6 @@ async def get_cascade_graph_tasks(
cognee_config = get_cognify_config()
default_tasks = [
Task(classify_documents),
Task(check_permissions_on_dataset, user=user, permissions=["write"]),
Task(
extract_chunks_from_documents, max_chunk_tokens=get_max_chunk_tokens()
), # Extract text chunks based on the document type.
Expand Down
2 changes: 1 addition & 1 deletion cognee/tasks/documents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .classify_documents import classify_documents
from .extract_chunks_from_documents import extract_chunks_from_documents
from .check_permissions_on_dataset import check_permissions_on_dataset

26 changes: 0 additions & 26 deletions cognee/tasks/documents/check_permissions_on_dataset.py

This file was deleted.