Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1fc5925
feat: adds new cachedb interface
hajdul88 Feb 2, 2026
86cc247
feat: adds SessionQAEntryValidationError
hajdul88 Feb 2, 2026
af7625a
Update exceptions.py
hajdul88 Feb 2, 2026
f3ca802
chore: updates cache db base class
hajdul88 Feb 2, 2026
5b6474d
feat: adds basic operations to RedisAdapter
hajdul88 Feb 2, 2026
462169f
chore: exposes get_cache_engine, config and QAentry model
hajdul88 Feb 2, 2026
1eab547
feat: adds SessionQAEntry model to validate updated and created entries
hajdul88 Feb 2, 2026
a4e0ce5
chore: deletes testing script from RedisAdapter
hajdul88 Feb 2, 2026
1807eaa
chore: renames delete since its deleting only one entry
hajdul88 Feb 2, 2026
89a3238
chore: adds prune to cache_db_interface
hajdul88 Feb 2, 2026
f9b6831
Adds prune to RedisAdapter
hajdul88 Feb 2, 2026
d590334
feat: adds prune to redis + cache deletion to prune_system
hajdul88 Feb 2, 2026
b703ac6
feat: adds elementary crud operations + prune to FSCacheAdapter
hajdul88 Feb 2, 2026
aeabab0
chore: fixes ruff formatting
hajdul88 Feb 2, 2026
644c4ff
Update prune_system.py
hajdul88 Feb 2, 2026
26a9791
Revert "Update prune_system.py"
hajdul88 Feb 2, 2026
202ae9e
fixing cache engine prune
hajdul88 Feb 2, 2026
1a4bdcc
Revert "fixing cache engine prune"
hajdul88 Feb 2, 2026
0a5ff57
Reapply "fixing cache engine prune"
hajdul88 Feb 2, 2026
d2e11a6
chore: deletes prune from usage logger test
hajdul88 Feb 2, 2026
d0477dc
feat: adds unit tests to test CRUD in RedisAdapter
hajdul88 Feb 2, 2026
79ef638
chore: renames redis test
hajdul88 Feb 2, 2026
30c917b
feat: adds unit test for fs adapter crud operations
hajdul88 Feb 2, 2026
863eadb
feat: adds backward compatibility adapter level tests
hajdul88 Feb 2, 2026
fa98d99
hopefully fixes the windows FSAdapter CRUD test
hajdul88 Feb 2, 2026
8b034c5
feat: adds clear feedback operation
hajdul88 Feb 2, 2026
6b20117
feat: adds clear feedback tests
hajdul88 Feb 2, 2026
b5bff23
chore: renames delete feedback to match with session manager wording
hajdul88 Feb 2, 2026
210a1f3
feat: adds initial state of the session manager
hajdul88 Feb 2, 2026
05dce8f
Revert "feat: adds initial state of the session manager"
hajdul88 Feb 3, 2026
761f94b
Merge branch 'dev' into feature/cog-3879-enable-crud-in-session-and-i…
hajdul88 Feb 3, 2026
dcc5164
fix: fixed ttl preservation bug
hajdul88 Feb 3, 2026
f28e5cf
fixes unit test
hajdul88 Feb 3, 2026
3271b39
removes ttl from sessions due to inability to support it via FS
hajdul88 Feb 3, 2026
a842a32
removes unused params
hajdul88 Feb 3, 2026
5cb62ce
Merge branch 'dev' into feature/cog-3879-enable-crud-in-session-and-i…
hajdul88 Feb 3, 2026
0f50e16
Merge branch 'dev' into feature/cog-3879-enable-crud-in-session-and-i…
lxobr Feb 6, 2026
675b2d2
Merge branch 'dev' into feature/cog-3879-enable-crud-in-session-and-i…
lxobr Feb 6, 2026
25af5e4
Merge branch 'dev' into feature/cog-3879-enable-crud-in-session-and-i…
hajdul88 Feb 9, 2026
4850896
Merge branch 'dev' into feature/cog-3879-enable-crud-in-session-and-i…
hajdul88 Feb 9, 2026
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
5 changes: 4 additions & 1 deletion cognee/infrastructure/databases/cache/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from .get_cache_engine import get_cache_engine
from .config import get_cache_config
from .get_cache_engine import get_cache_engine
from .models import SessionQAEntry

__all__ = ["get_cache_engine", "get_cache_config", "SessionQAEntry"]
90 changes: 85 additions & 5 deletions cognee/infrastructure/databases/cache/cache_db_interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from abc import ABC, abstractmethod
from contextlib import contextmanager

Expand Down Expand Up @@ -44,36 +45,115 @@ def hold_lock(self):
finally:
self.release()

@abstractmethod
async def add_qa(
self,
user_id: str,
session_id: str,
question: str,
context: str,
answer: str,
ttl: int | None = 86400,
):
"""Backward-compatibility: delegates to create_qa_entry with generated qa_id. :TODO: delete when retrievers are updated"""
return await self.create_qa_entry(
user_id,
session_id,
question,
context,
answer,
qa_id=str(uuid.uuid4()),
)

@abstractmethod
async def create_qa_entry(
self,
user_id: str,
session_id: str,
question: str,
context: str,
answer: str,
qa_id: str,
feedback_text: str | None = None,
feedback_score: int | None = None,
):
"""
Add a Q/A/context triplet to a cache session.
Uses the same QA fields as update_qa_entry for consistent structure.
"""

pass

@abstractmethod
async def get_latest_qa(self, user_id: str, session_id: str, last_n: int = 5):
"""Backward-compat: delegates to get_latest_qa_entries. :TODO: delete when retrievers are updated"""
return await self.get_latest_qa_entries(user_id, session_id, last_n)

@abstractmethod
async def get_latest_qa_entries(self, user_id: str, session_id: str, last_n: int = 5):
"""
Retrieve the most recent Q/A/context triplets for a session.
"""
pass

@abstractmethod
async def get_all_qas(self, user_id: str, session_id: str):
"""Backward-compat: delegates to get_all_qa_entries. :TODO: delete when retrievers are updated"""
return await self.get_all_qa_entries(user_id, session_id)

@abstractmethod
async def get_all_qa_entries(self, user_id: str, session_id: str):
"""
Retrieve all Q/A/context triplets for the given session.
"""
pass

@abstractmethod
async def update_qa_entry(
self,
user_id: str,
session_id: str,
qa_id: str,
question: str | None = None,
context: str | None = None,
answer: str | None = None,
feedback_text: str | None = None,
feedback_score: int | None = None,
) -> bool:
"""
Update a QA entry by qa_id. Same QA fields as create_qa_entry.
Only passed fields are updated; None/default preserves existing values.
Returns True if updated, False if qa_id not found.
"""
pass

@abstractmethod
async def delete_feedback(self, user_id: str, session_id: str, qa_id: str) -> bool:
"""
Set feedback_text and feedback_score to None for a QA entry (clears feedback).
Returns True if updated, False if qa_id not found.
"""
pass

@abstractmethod
async def delete_qa_entry(self, user_id: str, session_id: str, qa_id: str) -> bool:
"""
Delete a single QA entry by qa_id.
Returns True if deleted, False if qa_id not found.
"""
pass

@abstractmethod
async def delete_session(self, user_id: str, session_id: str) -> bool:
"""
Delete the entire session and all its QA entries.
Returns True if deleted, False if session did not exist.
"""
pass

@abstractmethod
async def prune(self) -> None:
"""
Delete the entire cache (flush Redis db or delete FS cache directory).
In Cognee, prune means wiping the whole cache storage.
"""
pass

@abstractmethod
async def close(self):
"""
Expand Down
Loading
Loading