cognee 0.3.4.dev3__py3-none-any.whl → 0.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cognee/api/client.py +16 -7
- cognee/api/health.py +5 -9
- cognee/api/v1/add/add.py +3 -1
- cognee/api/v1/cognify/cognify.py +44 -7
- cognee/api/v1/permissions/routers/get_permissions_router.py +8 -4
- cognee/api/v1/search/search.py +3 -0
- cognee/api/v1/ui/__init__.py +1 -1
- cognee/api/v1/ui/ui.py +215 -150
- cognee/api/v1/update/__init__.py +1 -0
- cognee/api/v1/update/routers/__init__.py +1 -0
- cognee/api/v1/update/routers/get_update_router.py +90 -0
- cognee/api/v1/update/update.py +100 -0
- cognee/base_config.py +5 -2
- cognee/cli/_cognee.py +28 -10
- cognee/cli/commands/delete_command.py +34 -2
- cognee/eval_framework/corpus_builder/task_getters/get_default_tasks_by_indices.py +2 -2
- cognee/eval_framework/evaluation/direct_llm_eval_adapter.py +3 -2
- cognee/eval_framework/modal_eval_dashboard.py +9 -1
- cognee/infrastructure/databases/graph/config.py +9 -9
- cognee/infrastructure/databases/graph/get_graph_engine.py +4 -21
- cognee/infrastructure/databases/graph/kuzu/adapter.py +60 -9
- cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py +3 -3
- cognee/infrastructure/databases/relational/config.py +4 -4
- cognee/infrastructure/databases/relational/create_relational_engine.py +11 -3
- cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py +7 -3
- cognee/infrastructure/databases/vector/config.py +7 -7
- cognee/infrastructure/databases/vector/create_vector_engine.py +7 -15
- cognee/infrastructure/databases/vector/embeddings/EmbeddingEngine.py +9 -0
- cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +11 -0
- cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +19 -2
- cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +11 -0
- cognee/infrastructure/databases/vector/embeddings/config.py +8 -0
- cognee/infrastructure/databases/vector/embeddings/get_embedding_engine.py +5 -0
- cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +11 -10
- cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py +48 -38
- cognee/infrastructure/databases/vector/vector_db_interface.py +8 -4
- cognee/infrastructure/files/storage/S3FileStorage.py +15 -5
- cognee/infrastructure/files/storage/s3_config.py +1 -0
- cognee/infrastructure/files/utils/open_data_file.py +7 -14
- cognee/infrastructure/llm/LLMGateway.py +19 -117
- cognee/infrastructure/llm/config.py +28 -13
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_categories.py +2 -1
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_event_entities.py +3 -2
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_summary.py +3 -2
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_content_graph.py +2 -1
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_event_graph.py +3 -2
- cognee/infrastructure/llm/prompts/read_query_prompt.py +3 -2
- cognee/infrastructure/llm/prompts/show_prompt.py +35 -0
- cognee/infrastructure/llm/prompts/test.txt +1 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/__init__.py +2 -2
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/async_client.py +50 -397
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/inlinedbaml.py +2 -3
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/parser.py +8 -88
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/runtime.py +78 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/stream_types.py +2 -99
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/sync_client.py +49 -401
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_builder.py +19 -882
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_map.py +2 -34
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/types.py +2 -107
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/acreate_structured_output.baml +26 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/__init__.py +1 -2
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/acreate_structured_output.py +76 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/create_dynamic_baml_type.py +122 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/generators.baml +3 -3
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +0 -32
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +107 -98
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +5 -6
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +5 -6
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/llm_interface.py +0 -26
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +17 -67
- cognee/infrastructure/llm/tokenizer/Gemini/adapter.py +8 -7
- cognee/infrastructure/llm/utils.py +4 -4
- cognee/infrastructure/loaders/LoaderEngine.py +5 -2
- cognee/infrastructure/loaders/external/__init__.py +7 -0
- cognee/infrastructure/loaders/external/advanced_pdf_loader.py +244 -0
- cognee/infrastructure/loaders/supported_loaders.py +7 -0
- cognee/modules/data/methods/create_authorized_dataset.py +9 -0
- cognee/modules/data/methods/get_authorized_dataset.py +1 -1
- cognee/modules/data/methods/get_authorized_dataset_by_name.py +11 -0
- cognee/modules/data/methods/get_deletion_counts.py +92 -0
- cognee/modules/graph/cognee_graph/CogneeGraph.py +1 -1
- cognee/modules/graph/utils/expand_with_nodes_and_edges.py +22 -8
- cognee/modules/graph/utils/retrieve_existing_edges.py +0 -2
- cognee/modules/ingestion/data_types/TextData.py +0 -1
- cognee/modules/notebooks/methods/create_notebook.py +3 -1
- cognee/modules/notebooks/methods/get_notebooks.py +27 -1
- cognee/modules/observability/get_observe.py +14 -0
- cognee/modules/observability/observers.py +1 -0
- cognee/modules/ontology/base_ontology_resolver.py +42 -0
- cognee/modules/ontology/get_default_ontology_resolver.py +41 -0
- cognee/modules/ontology/matching_strategies.py +53 -0
- cognee/modules/ontology/models.py +20 -0
- cognee/modules/ontology/ontology_config.py +24 -0
- cognee/modules/ontology/ontology_env_config.py +45 -0
- cognee/modules/ontology/rdf_xml/{OntologyResolver.py → RDFLibOntologyResolver.py} +20 -28
- cognee/modules/pipelines/layers/resolve_authorized_user_dataset.py +21 -24
- cognee/modules/pipelines/layers/resolve_authorized_user_datasets.py +3 -3
- cognee/modules/retrieval/code_retriever.py +2 -1
- cognee/modules/retrieval/context_providers/TripletSearchContextProvider.py +1 -4
- cognee/modules/retrieval/graph_completion_cot_retriever.py +6 -5
- cognee/modules/retrieval/graph_completion_retriever.py +0 -3
- cognee/modules/retrieval/insights_retriever.py +1 -1
- cognee/modules/retrieval/jaccard_retrival.py +60 -0
- cognee/modules/retrieval/lexical_retriever.py +123 -0
- cognee/modules/retrieval/natural_language_retriever.py +2 -1
- cognee/modules/retrieval/temporal_retriever.py +3 -2
- cognee/modules/retrieval/utils/brute_force_triplet_search.py +2 -12
- cognee/modules/retrieval/utils/completion.py +4 -7
- cognee/modules/search/methods/get_search_type_tools.py +7 -0
- cognee/modules/search/methods/no_access_control_search.py +1 -1
- cognee/modules/search/methods/search.py +32 -13
- cognee/modules/search/types/SearchType.py +1 -0
- cognee/modules/users/methods/create_user.py +0 -2
- cognee/modules/users/permissions/methods/authorized_give_permission_on_datasets.py +12 -0
- cognee/modules/users/permissions/methods/check_permission_on_dataset.py +11 -0
- cognee/modules/users/permissions/methods/get_all_user_permission_datasets.py +10 -0
- cognee/modules/users/permissions/methods/get_document_ids_for_user.py +10 -0
- cognee/modules/users/permissions/methods/get_principal.py +9 -0
- cognee/modules/users/permissions/methods/get_principal_datasets.py +11 -0
- cognee/modules/users/permissions/methods/get_role.py +10 -0
- cognee/modules/users/permissions/methods/get_specific_user_permission_datasets.py +3 -3
- cognee/modules/users/permissions/methods/get_tenant.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_role.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_tenant.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_user.py +9 -0
- cognee/modules/users/permissions/methods/give_permission_on_dataset.py +10 -0
- cognee/modules/users/roles/methods/add_user_to_role.py +11 -0
- cognee/modules/users/roles/methods/create_role.py +12 -1
- cognee/modules/users/tenants/methods/add_user_to_tenant.py +12 -0
- cognee/modules/users/tenants/methods/create_tenant.py +12 -1
- cognee/modules/visualization/cognee_network_visualization.py +13 -9
- cognee/shared/data_models.py +0 -1
- cognee/shared/utils.py +0 -32
- cognee/tasks/chunk_naive_llm_classifier/chunk_naive_llm_classifier.py +2 -2
- cognee/tasks/codingagents/coding_rule_associations.py +3 -2
- cognee/tasks/entity_completion/entity_extractors/llm_entity_extractor.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_content_nodes_and_relationship_names.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_edge_triplets.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_nodes.py +3 -2
- cognee/tasks/graph/extract_graph_from_code.py +2 -2
- cognee/tasks/graph/extract_graph_from_data.py +55 -12
- cognee/tasks/graph/extract_graph_from_data_v2.py +16 -4
- cognee/tasks/ingestion/migrate_relational_database.py +132 -41
- cognee/tasks/ingestion/resolve_data_directories.py +4 -1
- cognee/tasks/schema/ingest_database_schema.py +134 -0
- cognee/tasks/schema/models.py +40 -0
- cognee/tasks/storage/index_data_points.py +1 -1
- cognee/tasks/storage/index_graph_edges.py +3 -1
- cognee/tasks/summarization/summarize_code.py +2 -2
- cognee/tasks/summarization/summarize_text.py +2 -2
- cognee/tasks/temporal_graph/enrich_events.py +2 -2
- cognee/tasks/temporal_graph/extract_events_and_entities.py +2 -2
- cognee/tests/cli_tests/cli_unit_tests/test_cli_commands.py +13 -4
- cognee/tests/cli_tests/cli_unit_tests/test_cli_edge_cases.py +13 -3
- cognee/tests/test_advanced_pdf_loader.py +141 -0
- cognee/tests/test_chromadb.py +40 -0
- cognee/tests/test_cognee_server_start.py +6 -1
- cognee/tests/test_data/Quantum_computers.txt +9 -0
- cognee/tests/test_lancedb.py +211 -0
- cognee/tests/test_pgvector.py +40 -0
- cognee/tests/test_relational_db_migration.py +76 -0
- cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py +2 -1
- cognee/tests/unit/modules/ontology/test_ontology_adapter.py +330 -13
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_context_extension_test.py +0 -4
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +0 -4
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +0 -4
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/METADATA +92 -96
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/RECORD +176 -162
- distributed/pyproject.toml +0 -1
- cognee/infrastructure/data/utils/extract_keywords.py +0 -48
- cognee/infrastructure/databases/hybrid/falkordb/FalkorDBAdapter.py +0 -1227
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_categories.baml +0 -109
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_content_graph.baml +0 -343
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_categories.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_summary.py +0 -89
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/__init__.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/extract_content_graph.py +0 -44
- cognee/tasks/graph/infer_data_ontology.py +0 -309
- cognee/tests/test_falkordb.py +0 -174
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/__init__.py +0 -0
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/__init__.py +0 -0
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/texts.json +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/WHEEL +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/entry_points.txt +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/licenses/NOTICE.md +0 -0
cognee/api/client.py
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
5
|
import uvicorn
|
|
6
|
-
import sentry_sdk
|
|
7
6
|
from traceback import format_exc
|
|
8
7
|
from contextlib import asynccontextmanager
|
|
9
8
|
from fastapi import Request
|
|
@@ -29,6 +28,7 @@ from cognee.api.v1.add.routers import get_add_router
|
|
|
29
28
|
from cognee.api.v1.delete.routers import get_delete_router
|
|
30
29
|
from cognee.api.v1.responses.routers import get_responses_router
|
|
31
30
|
from cognee.api.v1.sync.routers import get_sync_router
|
|
31
|
+
from cognee.api.v1.update.routers import get_update_router
|
|
32
32
|
from cognee.api.v1.users.routers import (
|
|
33
33
|
get_auth_router,
|
|
34
34
|
get_register_router,
|
|
@@ -42,11 +42,18 @@ from cognee.modules.users.methods.get_authenticated_user import REQUIRE_AUTHENTI
|
|
|
42
42
|
logger = get_logger()
|
|
43
43
|
|
|
44
44
|
if os.getenv("ENV", "prod") == "prod":
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
try:
|
|
46
|
+
import sentry_sdk
|
|
47
|
+
|
|
48
|
+
sentry_sdk.init(
|
|
49
|
+
dsn=os.getenv("SENTRY_REPORTING_URL"),
|
|
50
|
+
traces_sample_rate=1.0,
|
|
51
|
+
profiles_sample_rate=1.0,
|
|
52
|
+
)
|
|
53
|
+
except ImportError:
|
|
54
|
+
logger.info(
|
|
55
|
+
"Sentry SDK not available. Install with 'pip install cognee\"[monitoring]\"' to enable error monitoring."
|
|
56
|
+
)
|
|
50
57
|
|
|
51
58
|
|
|
52
59
|
app_environment = os.getenv("ENV", "prod")
|
|
@@ -81,7 +88,7 @@ if CORS_ALLOWED_ORIGINS:
|
|
|
81
88
|
]
|
|
82
89
|
else:
|
|
83
90
|
allowed_origins = [
|
|
84
|
-
"http://localhost:3000",
|
|
91
|
+
os.getenv("UI_APP_URL", "http://localhost:3000"),
|
|
85
92
|
] # Block all except explicitly set origins
|
|
86
93
|
|
|
87
94
|
app.add_middleware(
|
|
@@ -257,6 +264,8 @@ app.include_router(get_visualize_router(), prefix="/api/v1/visualize", tags=["vi
|
|
|
257
264
|
|
|
258
265
|
app.include_router(get_delete_router(), prefix="/api/v1/delete", tags=["delete"])
|
|
259
266
|
|
|
267
|
+
app.include_router(get_update_router(), prefix="/api/v1/update", tags=["update"])
|
|
268
|
+
|
|
260
269
|
app.include_router(get_responses_router(), prefix="/api/v1/responses", tags=["responses"])
|
|
261
270
|
|
|
262
271
|
app.include_router(get_sync_router(), prefix="/api/v1/sync", tags=["sync"])
|
cognee/api/health.py
CHANGED
|
@@ -189,12 +189,12 @@ class HealthChecker:
|
|
|
189
189
|
start_time = time.time()
|
|
190
190
|
try:
|
|
191
191
|
from cognee.infrastructure.llm.config import get_llm_config
|
|
192
|
-
from cognee.infrastructure.llm import LLMGateway
|
|
193
192
|
|
|
194
193
|
config = get_llm_config()
|
|
195
194
|
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
from cognee.infrastructure.llm.utils import test_llm_connection
|
|
196
|
+
|
|
197
|
+
await test_llm_connection()
|
|
198
198
|
|
|
199
199
|
response_time = int((time.time() - start_time) * 1000)
|
|
200
200
|
return ComponentHealth(
|
|
@@ -217,13 +217,9 @@ class HealthChecker:
|
|
|
217
217
|
"""Check embedding service health (non-critical)."""
|
|
218
218
|
start_time = time.time()
|
|
219
219
|
try:
|
|
220
|
-
from cognee.infrastructure.
|
|
221
|
-
get_embedding_engine,
|
|
222
|
-
)
|
|
220
|
+
from cognee.infrastructure.llm.utils import test_embedding_connection
|
|
223
221
|
|
|
224
|
-
|
|
225
|
-
engine = get_embedding_engine()
|
|
226
|
-
await engine.embed_text(["test"])
|
|
222
|
+
await test_embedding_connection()
|
|
227
223
|
|
|
228
224
|
response_time = int((time.time() - start_time) * 1000)
|
|
229
225
|
return ComponentHealth(
|
cognee/api/v1/add/add.py
CHANGED
|
@@ -148,7 +148,9 @@ async def add(
|
|
|
148
148
|
|
|
149
149
|
await setup()
|
|
150
150
|
|
|
151
|
-
user, authorized_dataset = await resolve_authorized_user_dataset(
|
|
151
|
+
user, authorized_dataset = await resolve_authorized_user_dataset(
|
|
152
|
+
dataset_name=dataset_name, dataset_id=dataset_id, user=user
|
|
153
|
+
)
|
|
152
154
|
|
|
153
155
|
await reset_dataset_pipeline_run_status(
|
|
154
156
|
authorized_dataset.id, user, pipeline_names=["add_pipeline", "cognify_pipeline"]
|
cognee/api/v1/cognify/cognify.py
CHANGED
|
@@ -3,6 +3,7 @@ from pydantic import BaseModel
|
|
|
3
3
|
from typing import Union, Optional
|
|
4
4
|
from uuid import UUID
|
|
5
5
|
|
|
6
|
+
from cognee.modules.ontology.ontology_env_config import get_ontology_env_config
|
|
6
7
|
from cognee.shared.logging_utils import get_logger
|
|
7
8
|
from cognee.shared.data_models import KnowledgeGraph
|
|
8
9
|
from cognee.infrastructure.llm import get_max_chunk_tokens
|
|
@@ -10,7 +11,11 @@ from cognee.infrastructure.llm import get_max_chunk_tokens
|
|
|
10
11
|
from cognee.modules.pipelines import run_pipeline
|
|
11
12
|
from cognee.modules.pipelines.tasks.task import Task
|
|
12
13
|
from cognee.modules.chunking.TextChunker import TextChunker
|
|
13
|
-
from cognee.modules.ontology.
|
|
14
|
+
from cognee.modules.ontology.ontology_config import Config
|
|
15
|
+
from cognee.modules.ontology.get_default_ontology_resolver import (
|
|
16
|
+
get_default_ontology_resolver,
|
|
17
|
+
get_ontology_resolver_from_env,
|
|
18
|
+
)
|
|
14
19
|
from cognee.modules.users.models import User
|
|
15
20
|
|
|
16
21
|
from cognee.tasks.documents import (
|
|
@@ -39,7 +44,7 @@ async def cognify(
|
|
|
39
44
|
graph_model: BaseModel = KnowledgeGraph,
|
|
40
45
|
chunker=TextChunker,
|
|
41
46
|
chunk_size: int = None,
|
|
42
|
-
|
|
47
|
+
config: Config = None,
|
|
43
48
|
vector_db_config: dict = None,
|
|
44
49
|
graph_db_config: dict = None,
|
|
45
50
|
run_in_background: bool = False,
|
|
@@ -100,8 +105,6 @@ async def cognify(
|
|
|
100
105
|
Formula: min(embedding_max_completion_tokens, llm_max_completion_tokens // 2)
|
|
101
106
|
Default limits: ~512-8192 tokens depending on models.
|
|
102
107
|
Smaller chunks = more granular but potentially fragmented knowledge.
|
|
103
|
-
ontology_file_path: Path to RDF/OWL ontology file for domain-specific entity types.
|
|
104
|
-
Useful for specialized fields like medical or legal documents.
|
|
105
108
|
vector_db_config: Custom vector database configuration for embeddings storage.
|
|
106
109
|
graph_db_config: Custom graph database configuration for relationship storage.
|
|
107
110
|
run_in_background: If True, starts processing asynchronously and returns immediately.
|
|
@@ -188,11 +191,28 @@ async def cognify(
|
|
|
188
191
|
- LLM_RATE_LIMIT_ENABLED: Enable rate limiting (default: False)
|
|
189
192
|
- LLM_RATE_LIMIT_REQUESTS: Max requests per interval (default: 60)
|
|
190
193
|
"""
|
|
194
|
+
if config is None:
|
|
195
|
+
ontology_config = get_ontology_env_config()
|
|
196
|
+
if (
|
|
197
|
+
ontology_config.ontology_file_path
|
|
198
|
+
and ontology_config.ontology_resolver
|
|
199
|
+
and ontology_config.matching_strategy
|
|
200
|
+
):
|
|
201
|
+
config: Config = {
|
|
202
|
+
"ontology_config": {
|
|
203
|
+
"ontology_resolver": get_ontology_resolver_from_env(**ontology_config.to_dict())
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else:
|
|
207
|
+
config: Config = {
|
|
208
|
+
"ontology_config": {"ontology_resolver": get_default_ontology_resolver()}
|
|
209
|
+
}
|
|
210
|
+
|
|
191
211
|
if temporal_cognify:
|
|
192
212
|
tasks = await get_temporal_tasks(user, chunker, chunk_size)
|
|
193
213
|
else:
|
|
194
214
|
tasks = await get_default_tasks(
|
|
195
|
-
user, graph_model, chunker, chunk_size,
|
|
215
|
+
user, graph_model, chunker, chunk_size, config, custom_prompt
|
|
196
216
|
)
|
|
197
217
|
|
|
198
218
|
# By calling get pipeline executor we get a function that will have the run_pipeline run in the background or a function that we will need to wait for
|
|
@@ -216,9 +236,26 @@ async def get_default_tasks( # TODO: Find out a better way to do this (Boris's
|
|
|
216
236
|
graph_model: BaseModel = KnowledgeGraph,
|
|
217
237
|
chunker=TextChunker,
|
|
218
238
|
chunk_size: int = None,
|
|
219
|
-
|
|
239
|
+
config: Config = None,
|
|
220
240
|
custom_prompt: Optional[str] = None,
|
|
221
241
|
) -> list[Task]:
|
|
242
|
+
if config is None:
|
|
243
|
+
ontology_config = get_ontology_env_config()
|
|
244
|
+
if (
|
|
245
|
+
ontology_config.ontology_file_path
|
|
246
|
+
and ontology_config.ontology_resolver
|
|
247
|
+
and ontology_config.matching_strategy
|
|
248
|
+
):
|
|
249
|
+
config: Config = {
|
|
250
|
+
"ontology_config": {
|
|
251
|
+
"ontology_resolver": get_ontology_resolver_from_env(**ontology_config.to_dict())
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else:
|
|
255
|
+
config: Config = {
|
|
256
|
+
"ontology_config": {"ontology_resolver": get_default_ontology_resolver()}
|
|
257
|
+
}
|
|
258
|
+
|
|
222
259
|
default_tasks = [
|
|
223
260
|
Task(classify_documents),
|
|
224
261
|
Task(check_permissions_on_dataset, user=user, permissions=["write"]),
|
|
@@ -230,7 +267,7 @@ async def get_default_tasks( # TODO: Find out a better way to do this (Boris's
|
|
|
230
267
|
Task(
|
|
231
268
|
extract_graph_from_data,
|
|
232
269
|
graph_model=graph_model,
|
|
233
|
-
|
|
270
|
+
config=config,
|
|
234
271
|
custom_prompt=custom_prompt,
|
|
235
272
|
task_config={"batch_size": 10},
|
|
236
273
|
), # Generate knowledge graphs from the document chunks.
|
|
@@ -94,9 +94,11 @@ def get_permissions_router() -> APIRouter:
|
|
|
94
94
|
|
|
95
95
|
from cognee.modules.users.roles.methods import create_role as create_role_method
|
|
96
96
|
|
|
97
|
-
await create_role_method(role_name=role_name, owner_id=user.id)
|
|
97
|
+
role_id = await create_role_method(role_name=role_name, owner_id=user.id)
|
|
98
98
|
|
|
99
|
-
return JSONResponse(
|
|
99
|
+
return JSONResponse(
|
|
100
|
+
status_code=200, content={"message": "Role created for tenant", "role_id": str(role_id)}
|
|
101
|
+
)
|
|
100
102
|
|
|
101
103
|
@permissions_router.post("/users/{user_id}/roles")
|
|
102
104
|
async def add_user_to_role(
|
|
@@ -212,8 +214,10 @@ def get_permissions_router() -> APIRouter:
|
|
|
212
214
|
|
|
213
215
|
from cognee.modules.users.tenants.methods import create_tenant as create_tenant_method
|
|
214
216
|
|
|
215
|
-
await create_tenant_method(tenant_name=tenant_name, user_id=user.id)
|
|
217
|
+
tenant_id = await create_tenant_method(tenant_name=tenant_name, user_id=user.id)
|
|
216
218
|
|
|
217
|
-
return JSONResponse(
|
|
219
|
+
return JSONResponse(
|
|
220
|
+
status_code=200, content={"message": "Tenant created.", "tenant_id": str(tenant_id)}
|
|
221
|
+
)
|
|
218
222
|
|
|
219
223
|
return permissions_router
|
cognee/api/v1/search/search.py
CHANGED
|
@@ -82,6 +82,9 @@ async def search(
|
|
|
82
82
|
Best for: General-purpose queries or when you're unsure which search type is best.
|
|
83
83
|
Returns: The results from the automatically selected search type.
|
|
84
84
|
|
|
85
|
+
**CHUNKS_LEXICAL**:
|
|
86
|
+
Token-based lexical chunk search (e.g., Jaccard). Best for: exact-term matching, stopword-aware lookups.
|
|
87
|
+
Returns: Ranked text chunks (optionally with scores).
|
|
85
88
|
|
|
86
89
|
Args:
|
|
87
90
|
query_text: Your question or search query in natural language.
|
cognee/api/v1/ui/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
from .ui import start_ui
|
|
1
|
+
from .ui import start_ui
|