Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
services:
redis:
image: redis/redis-stack-server:latest
Expand Down
5 changes: 4 additions & 1 deletion chatterbot/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,13 @@ def next_week_day(base_date: datetime, weekday: int) -> datetime:
return day


def datetime_parsing(text: str, base_date: datetime = datetime.now()) -> list[tuple[str, datetime, tuple[int, int]]]:
def datetime_parsing(text: str, base_date: datetime = None) -> list[tuple[str, datetime, tuple[int, int]]]:
"""
Extract datetime objects from a string of text.
"""
if base_date is None:
base_date = datetime.now()

matches = []
found_array = []

Expand Down
30 changes: 13 additions & 17 deletions chatterbot/storage/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,23 +350,20 @@ def filter(self, page_size=4, **kwargs):
filter_condition = query

if 'exclude_text' in kwargs:
query = Text('text') != '|'.join([
f'%%{text}%%' for text in kwargs['exclude_text']
])
if filter_condition:
filter_condition &= query
else:
filter_condition = query
for excl_text in kwargs['exclude_text']:
query = Text('text') != excl_text
if filter_condition:
filter_condition &= query
else:
filter_condition = query

if 'exclude_text_words' in kwargs and kwargs['exclude_text_words']:
_query = '|'.join([
f'%%{text}%%' for text in kwargs['exclude_text_words']
])
query = Text('text') % f'-({_query})'
if filter_condition:
filter_condition &= query
else:
filter_condition = query
for excl_word in kwargs['exclude_text_words']:
query = Text('text') % f'-({excl_word})'
if filter_condition:
filter_condition &= query
else:
filter_condition = query

if 'persona_not_startswith' in kwargs:
_query = _escape_redis_special_characters(kwargs['persona_not_startswith'])
Expand All @@ -377,8 +374,7 @@ def filter(self, page_size=4, **kwargs):
filter_condition = query

if 'text' in kwargs:
_query = _escape_redis_special_characters(kwargs['text'])
query = Text('text') % '|'.join([f'%%{_q}%%' for _q in _query.split()])
query = Text('text') == kwargs['text']
if filter_condition:
filter_condition &= query
else:
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ version = {attr = "chatterbot.__version__"}

[project]
name = "ChatterBot"
requires-python = ">=3.9,<3.14"
requires-python = ">=3.10,<3.15"
urls = { Documentation = "https://docs.chatterbot.us", Repository = "https://github.com/gunthercox/ChatterBot", Changelog = "https://github.com/gunthercox/ChatterBot/releases" }
description = "ChatterBot is a machine learning, conversational dialog engine"
authors = [
Expand Down Expand Up @@ -56,7 +56,7 @@ classifiers = [
"Topic :: Text Processing :: Linguistic",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
]
dependencies = [
Expand Down Expand Up @@ -84,10 +84,10 @@ dev = [
"openai"
]
redis = [
"redis[hiredis]>=7.0,<7.2",
"redis[hiredis]>=7.0,<7.3",
"langchain-redis<0.3.0",
"langchain-huggingface>=0.1.2,<1.3.0",
"accelerate>=1.6.0,<1.13",
"accelerate>=1.6.0,<1.14",
"sentence-transformers>=4.0.2,<5.3.0",
]
mongodb = [
Expand Down
6 changes: 3 additions & 3 deletions tests/storage/test_redis_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


@unittest.skipIf(
sys.version_info < (3, 10),
'The Redis adapter requires Python 3.10+'
)
sys.version_info >= (3, 14),
'redisvl depends on pydantic v1 which is incompatible with Python 3.14+'
) # TODO: Remove this skip when redisvl supports pydantic v2 and Python 3.14+

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm marking these as skipped for now since the redis storage adapter is new/still experimental. Before skipping, the error I'm seeing is:

======================================================================
ERROR: setUpClass (storage.test_redis_adapter.StorageAdapterUpdateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/ChatterBot/ChatterBot/tests/storage/test_redis_adapter.py", line 24, in setUpClass
    cls.adapter = RedisVectorStorageAdapter(
                  ~~~~~~~~~~~~~~~~~~~~~~~~~^
        database_uri='redis://localhost:6379/0'
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/runner/work/ChatterBot/ChatterBot/chatterbot/storage/redis.py", line 103, in __init__
    from chatterbot.vectorstores import RedisVectorStore
  File "/home/runner/work/ChatterBot/ChatterBot/chatterbot/vectorstores.py", line 9, in <module>
    from redisvl.redis.utils import convert_bytes
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/redisvl/redis/utils.py", line 7, in <module>
    from redisvl.schema.fields import VectorDataType
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/redisvl/schema/__init__.py", line 1, in <module>
    from redisvl.schema.schema import IndexInfo, IndexSchema, StorageType
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/redisvl/schema/schema.py", line 10, in <module>
    from redisvl.schema.fields import BaseField, FieldFactory
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/redisvl/schema/fields.py", line 50, in <module>
    class TextFieldAttributes(BaseFieldAttributes):
    ...<9 lines>...
        """Used to perform phonetic matching during search"""
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/pydantic/v1/main.py", line 221, in __new__
    inferred = ModelField.infer(
        name=var_name,
    ...<3 lines>...
        config=config,
    )
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 504, in infer
    return cls(
        name=name,
    ...<7 lines>...
        field_info=field_info,
    )
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 434, in __init__
    self.prepare()
    ~~~~~~~~~~~~^^
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 544, in prepare
    self._set_default_and_type()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 576, in _set_default_and_type
    raise errors_.ConfigError(f'unable to infer type for attribute "{self.name}"')
pydantic.v1.errors.ConfigError: unable to infer type for attribute "phonetic_matcher"

class RedisStorageAdapterTestCase(TestCase):

@classmethod
Expand Down
Loading