Fix: fixes session history test for multiuser mode (#1746)
<!-- .github/pull_request_template.md --> ## Description Fixes failing session history test ## Type of Change <!-- Please check the relevant option --> - [x] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Other (please specify): ## Screenshots/Videos (if applicable) <!-- Add screenshots or videos to help explain your changes --> ## Pre-submission Checklist <!-- Please check all boxes that apply before submitting your PR --> - [x] **I have tested my changes thoroughly before submitting this PR** - [x] **This PR contains minimal changes necessary to address the issue/feature** - [x] My code follows the project's coding standards and style guidelines - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have added necessary documentation (if applicable) - [x] All new and existing tests pass - [x] I have searched existing PRs to ensure this change hasn't been submitted already - [x] I have linked any relevant issues in the description - [x] My commits have clear and descriptive messages ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.
This commit is contained in:
parent
69c7aa2559
commit
c0e5ce04ce
4 changed files with 16 additions and 11 deletions
|
|
@ -40,7 +40,7 @@ async def persist_sessions_in_knowledge_graph_pipeline(
|
|||
extraction_tasks = [Task(extract_user_sessions, session_ids=session_ids)]
|
||||
|
||||
enrichment_tasks = [
|
||||
Task(cognify_session),
|
||||
Task(cognify_session, dataset_id=dataset_to_write[0].id),
|
||||
]
|
||||
|
||||
result = await memify(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from cognee.shared.logging_utils import get_logger
|
|||
logger = get_logger("cognify_session")
|
||||
|
||||
|
||||
async def cognify_session(data):
|
||||
async def cognify_session(data, dataset_id=None):
|
||||
"""
|
||||
Process and cognify session data into the knowledge graph.
|
||||
|
||||
|
|
@ -16,6 +16,7 @@ async def cognify_session(data):
|
|||
|
||||
Args:
|
||||
data: Session string containing Question, Context, and Answer information.
|
||||
dataset_name: Name of dataset.
|
||||
|
||||
Raises:
|
||||
CogneeValidationError: If data is None or empty.
|
||||
|
|
@ -28,9 +29,9 @@ async def cognify_session(data):
|
|||
|
||||
logger.info("Processing session data for cognification")
|
||||
|
||||
await cognee.add(data, node_set=["user_sessions_from_cache"])
|
||||
await cognee.add(data, dataset_id=dataset_id, node_set=["user_sessions_from_cache"])
|
||||
logger.debug("Session data added to cognee with node_set: user_sessions")
|
||||
await cognee.cognify()
|
||||
await cognee.cognify(datasets=[dataset_id])
|
||||
logger.info("Session data successfully cognified")
|
||||
|
||||
except CogneeValidationError:
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ async def main():
|
|||
"""DataCo is a data analytics company. They help businesses make sense of their data."""
|
||||
)
|
||||
|
||||
await cognee.add(text_1, dataset_name)
|
||||
await cognee.add(text_2, dataset_name)
|
||||
await cognee.add(data=text_1, dataset_name=dataset_name)
|
||||
await cognee.add(data=text_2, dataset_name=dataset_name)
|
||||
|
||||
await cognee.cognify([dataset_name])
|
||||
await cognee.cognify(datasets=[dataset_name])
|
||||
|
||||
user = await get_default_user()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ async def test_cognify_session_success():
|
|||
patch("cognee.add", new_callable=AsyncMock) as mock_add,
|
||||
patch("cognee.cognify", new_callable=AsyncMock) as mock_cognify,
|
||||
):
|
||||
await cognify_session(session_data)
|
||||
await cognify_session(session_data, dataset_id="123")
|
||||
|
||||
mock_add.assert_called_once_with(session_data, node_set=["user_sessions_from_cache"])
|
||||
mock_add.assert_called_once_with(
|
||||
session_data, dataset_id="123", node_set=["user_sessions_from_cache"]
|
||||
)
|
||||
mock_cognify.assert_called_once()
|
||||
|
||||
|
||||
|
|
@ -101,7 +103,9 @@ async def test_cognify_session_with_special_characters():
|
|||
patch("cognee.add", new_callable=AsyncMock) as mock_add,
|
||||
patch("cognee.cognify", new_callable=AsyncMock) as mock_cognify,
|
||||
):
|
||||
await cognify_session(session_data)
|
||||
await cognify_session(session_data, dataset_id="123")
|
||||
|
||||
mock_add.assert_called_once_with(session_data, node_set=["user_sessions_from_cache"])
|
||||
mock_add.assert_called_once_with(
|
||||
session_data, dataset_id="123", node_set=["user_sessions_from_cache"]
|
||||
)
|
||||
mock_cognify.assert_called_once()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue