Skip to content

Commit 97bc757

Browse files
committed
Update optional python dependencies
1 parent 97181bd commit 97bc757

10 files changed

Lines changed: 3840 additions & 19 deletions

chatterbot/storage/redis.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(self, **kwargs):
6565
index_name='chatterbot',
6666
redis_url=self.database_uri,
6767
content_field='in_response_to',
68+
legacy_key_format=False,
6869
metadata_schema=[
6970
{
7071
'name': 'conversation',
@@ -551,11 +552,8 @@ def update(self, statement):
551552
client = self.vector_store.index.client
552553
client.delete(statement.id)
553554

554-
# NOTE: langchain-redis has an inconsistency - it uses :: for auto-generated
555-
# IDs but : (single colon) when keys are explicitly provided
556-
if '::' in statement.id:
557-
key = statement.id.split('::', 1)[1]
558-
elif ':' in statement.id:
555+
# Extract the key from the full ID (format: prefix:key)
556+
if ':' in statement.id:
559557
key = statement.id.split(':', 1)[1]
560558
else:
561559
# If no delimiter found, use the entire ID as the key
@@ -564,13 +562,6 @@ def update(self, statement):
564562
ids = self.vector_store.add_texts(
565563
[document.page_content], [metadata], keys=[key]
566564
)
567-
568-
# Normalize the ID to use :: delimiter (if langchain-redis returned single colon)
569-
if ids and ':' in ids[0] and '::' not in ids[0]:
570-
# Replace first occurrence of single colon with double colon
571-
normalized_id = ids[0].replace(':', '::', 1)
572-
# Update the key in Redis to use the correct format
573-
client.rename(ids[0], normalized_id)
574565
else:
575566
self.vector_store.add_documents([document])
576567

0 commit comments

Comments
 (0)