ChatterBot 1.2.1__py3-none-any.whl → 1.2.3__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.
@@ -1,6 +1,4 @@
1
1
  import logging
2
- from chatterbot import languages
3
- from chatterbot.tagging import PosLemmaTagger
4
2
 
5
3
 
6
4
  class StorageAdapter(object):
@@ -17,11 +15,9 @@ class StorageAdapter(object):
17
15
  """
18
16
  self.logger = kwargs.get('logger', logging.getLogger(__name__))
19
17
 
20
- Tagger = kwargs.get('tagger', PosLemmaTagger)
21
-
22
- self.tagger = Tagger(language=kwargs.get(
23
- 'tagger_language', languages.ENG
24
- ))
18
+ self.raise_on_missing_search_text = kwargs.get(
19
+ 'raise_on_missing_search_text', True
20
+ )
25
21
 
26
22
  def get_model(self, model_name):
27
23
  """
@@ -116,6 +112,12 @@ class StorageAdapter(object):
116
112
  this parameter, then the statement will be included in the
117
113
  result set.
118
114
  Defaults to None
115
+
116
+ :param search_in_response_to: If the ``search_in_response_to`` field
117
+ of a statement contains a word that is in the string provided to
118
+ this parameter, then the statement will be included in the
119
+ result set.
120
+ Defaults to None
119
121
  """
120
122
  raise self.AdapterMethodNotImplementedError(
121
123
  'The `filter` method is not implemented by this adapter.'
chatterbot/trainers.py CHANGED
@@ -93,7 +93,7 @@ class ListTrainer(Trainer):
93
93
  statements_to_create = []
94
94
 
95
95
  # Run the pipeline in bulk to improve performance
96
- documents = self.chatbot.storage.tagger.as_nlp_pipeline(conversation)
96
+ documents = self.chatbot.tagger.as_nlp_pipeline(conversation)
97
97
 
98
98
  # for text in enumerate(conversation):
99
99
  for document in tqdm(documents, desc='List Trainer', disable=not self.show_training_progress):
@@ -143,7 +143,7 @@ class ChatterBotCorpusTrainer(Trainer):
143
143
  for conversation in corpus:
144
144
 
145
145
  # Run the pipeline in bulk to improve performance
146
- documents = self.chatbot.storage.tagger.as_nlp_pipeline(conversation)
146
+ documents = self.chatbot.tagger.as_nlp_pipeline(conversation)
147
147
 
148
148
  previous_statement_text = None
149
149
  previous_statement_search_text = ''
@@ -344,7 +344,7 @@ class UbuntuCorpusTrainer(Trainer):
344
344
  previous_statement_text = None
345
345
  previous_statement_search_text = ''
346
346
 
347
- documents = self.chatbot.storage.tagger.as_nlp_pipeline([
347
+ documents = self.chatbot.tagger.as_nlp_pipeline([
348
348
  (
349
349
  row[3],
350
350
  {
@@ -0,0 +1,74 @@
1
+ """
2
+ Redis vector store.
3
+ """
4
+ from __future__ import annotations
5
+
6
+ from typing import Any, List, Sequence
7
+
8
+ from langchain_core.documents import Document
9
+ from redisvl.redis.utils import convert_bytes
10
+ from redisvl.query import FilterQuery
11
+
12
+ from langchain_core.documents import Document
13
+ from langchain_redis.vectorstores import RedisVectorStore as LangChainRedisVectorStore
14
+
15
+
16
+ class RedisVectorStore(LangChainRedisVectorStore):
17
+ """
18
+ Redis vector store integration.
19
+ """
20
+
21
+ def query_search(
22
+ self,
23
+ k=4,
24
+ filter=None,
25
+ sort_by=None,
26
+ ) -> List[Document]:
27
+ """
28
+ Return docs based on the provided query.
29
+
30
+ k: int, default=4
31
+ Number of documents to return.
32
+ filter: str, default=None
33
+ A filter expression to apply to the query.
34
+ sort_by: str, default=None
35
+ A field to sort the results by.
36
+
37
+ returns:
38
+ A list of Documents most matching the query.
39
+ """
40
+ from chatterbot import ChatBot
41
+
42
+ return_fields = [
43
+ self.config.content_field
44
+ ]
45
+ return_fields += [
46
+ field.name
47
+ for field in self._index.schema.fields.values()
48
+ if field.name
49
+ not in [self.config.embedding_field, self.config.content_field]
50
+ ]
51
+
52
+ query = FilterQuery(
53
+ return_fields=return_fields,
54
+ num_results=k,
55
+ filter_expression=filter,
56
+ sort_by=sort_by,
57
+ )
58
+
59
+ try:
60
+ results = self._index.query(query)
61
+ except Exception as e:
62
+ raise ChatBot.ChatBotException(f'Error querying index: {query}') from e
63
+
64
+ if results:
65
+ with self._index.client.pipeline(transaction=False) as pipe:
66
+ for document in results:
67
+ pipe.hgetall(document['id'])
68
+ full_documents = convert_bytes(pipe.execute())
69
+ else:
70
+ full_documents = []
71
+
72
+ return self._prepare_docs_full(
73
+ True, results, full_documents, True
74
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ChatterBot
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: ChatterBot is a machine learning, conversational dialog engine
5
5
  Author: Gunther Cox
6
6
  License: Copyright (c) 2016 - 2025, Gunther Cox
@@ -53,11 +53,18 @@ Requires-Dist: flake8; extra == "test"
53
53
  Requires-Dist: coverage; extra == "test"
54
54
  Requires-Dist: nose; extra == "test"
55
55
  Requires-Dist: sphinx<8.2,>=5.3; extra == "test"
56
+ Requires-Dist: sphinx-sitemap>=2.6.0; extra == "test"
56
57
  Provides-Extra: dev
57
58
  Requires-Dist: pint>=0.8.1; extra == "dev"
58
- Requires-Dist: pymongo<4.12,>=4.11; extra == "dev"
59
59
  Requires-Dist: pyyaml<7.0,>=6.0; extra == "dev"
60
60
  Requires-Dist: chatterbot-corpus>=1.2.2; extra == "dev"
61
+ Provides-Extra: redis
62
+ Requires-Dist: redis[hiredis]; extra == "redis"
63
+ Requires-Dist: langchain-redis; extra == "redis"
64
+ Requires-Dist: langchain-huggingface; extra == "redis"
65
+ Requires-Dist: sentence-transformers; extra == "redis"
66
+ Provides-Extra: mongodb
67
+ Requires-Dist: pymongo<4.12,>=4.11; extra == "mongodb"
61
68
 
62
69
  ![ChatterBot: Machine learning in Python](https://i.imgur.com/b3SCmGT.png)
63
70
 
@@ -70,7 +77,6 @@ to be trained to speak any language.
70
77
 
71
78
  [![Package Version](https://img.shields.io/pypi/v/chatterbot.svg)](https://pypi.python.org/pypi/chatterbot/)
72
79
  [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-360/)
73
- [![Django 2.0](https://img.shields.io/badge/Django-2.0-blue.svg)](https://docs.djangoproject.com/en/2.1/releases/2.0/)
74
80
  [![Coverage Status](https://img.shields.io/coveralls/gunthercox/ChatterBot.svg)](https://coveralls.io/r/gunthercox/ChatterBot)
75
81
  [![Code Climate](https://codeclimate.com/github/gunthercox/ChatterBot/badges/gpa.svg)](https://codeclimate.com/github/gunthercox/ChatterBot)
76
82
  [![Join the chat at https://gitter.im/chatterbot/Lobby](https://badges.gitter.im/chatterbot/Lobby.svg)](https://gitter.im/chatterbot/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge)
@@ -1,8 +1,8 @@
1
- chatterbot/__init__.py,sha256=Edfsbjoii_j0I4OOI1p1JLwfVRpwUW_8NhjfoNuvZRI,158
1
+ chatterbot/__init__.py,sha256=PhC2oXazQN3HNYXvWb33IAqEzwyt5QtqcfESq8eg3sg,158
2
2
  chatterbot/__main__.py,sha256=nk19D56TlPT9Zdqkq4qZZrOnLKEc4YTwUVWmXYwSyHg,207
3
3
  chatterbot/adapters.py,sha256=LJ_KqLpHKPdYAFpMGK63RVH4weV5X0Zh5uGyan6qdVU,878
4
- chatterbot/chatterbot.py,sha256=WhV4sSa8psrm6DebtAewIEwkz3MrnjWRftQeZMQso2w,9328
5
- chatterbot/comparisons.py,sha256=bSVTsCbFEiyVv0Rg60addtrxgjbG3QlJa3murgDWkws,6145
4
+ chatterbot/chatterbot.py,sha256=YLKLkQ-XI4Unr3rbzjpGIupOqenuevm21tAnx-yFFgQ,10400
5
+ chatterbot/comparisons.py,sha256=8-qLFWC1Z7tZ3iPUpyY6AD9l-whSo3QE1Rno_SzIp-I,6570
6
6
  chatterbot/components.py,sha256=ld3Xam8olBClvE5QqcFYggE7Q7tODCFek7BO7lhfyeU,1782
7
7
  chatterbot/constants.py,sha256=c_KPQKc82CHX6H3maeyTYqWatx6j-N-8HJhmejoVi60,1875
8
8
  chatterbot/conversation.py,sha256=Y-WOxPN7I3igRyAEe5py1sfS6JIYPdbwjVlY3kM8Ys8,3175
@@ -12,11 +12,12 @@ chatterbot/filters.py,sha256=vDSDJz2FM10xT6ybs7qJiqy4X5I4gTEfwEnjBGUxZ9g,847
12
12
  chatterbot/languages.py,sha256=XSenfc5FxHk_JWG5gGHsZvjvrPBbCaVCm_OU-BeER_M,32784
13
13
  chatterbot/parsing.py,sha256=vS-w70cMkjq4YEpDOv_pXWhAI6Zj06WYDAcMDhYDj0M,23174
14
14
  chatterbot/preprocessors.py,sha256=aI4v987dZc7GOKhO43i0i73EX748hehYSpzikFHpEXs,1271
15
- chatterbot/response_selection.py,sha256=9E7CJKlC3UCHTGvEmYvfE9cEHOltJeU77z9NfRzmeB8,2950
16
- chatterbot/search.py,sha256=Bx6j_NIdp7YDnJvunE7rmk9ma37AKYw96R0iu2i4chc,5141
15
+ chatterbot/response_selection.py,sha256=aYeZ54jpGIcQnI-1-TDcua_f1p3PiM5_iMg4hF5ZaIU,2951
16
+ chatterbot/search.py,sha256=S4MFL1JzPqT-pv7tCgd-MIqf0T9Ia_KOLoNgzdoCP4Y,7035
17
17
  chatterbot/tagging.py,sha256=GLY9wg_rvn6pSYVML-HcxkIo_3BZ3SAyj-q1oNZY8pI,2584
18
- chatterbot/trainers.py,sha256=4u6RDRPpAnecTEAOrGcDvMTjEn8Kxn8slM4UnovDvNk,13339
18
+ chatterbot/trainers.py,sha256=U1yh0_V7FFL51MeQe1P1Q59weceDbkHh_2kDiDYpSEc,13315
19
19
  chatterbot/utils.py,sha256=ckQXvsjp2FO9GcWxziY67JovN7mShnE4RlzdYarQY5k,3277
20
+ chatterbot/vectorstores.py,sha256=-S1NB8PrZzoFIu95n2W7N4UaXuCUpyDUXIGYFebjv08,2056
20
21
  chatterbot/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
22
  chatterbot/ext/django_chatterbot/__init__.py,sha256=iWzmBzpAsYwkwi1faxAPFY9L1bbL97RgVXK2uqULIMc,92
22
23
  chatterbot/ext/django_chatterbot/abstract_models.py,sha256=PkuBGS0uv2toL3jGE1U6HJLCLXoKwpRNohm9JbVT_y4,3303
@@ -48,19 +49,20 @@ chatterbot/ext/django_chatterbot/migrations/__init__.py,sha256=47DEQpj8HBSa-_TIm
48
49
  chatterbot/ext/sqlalchemy_app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
50
  chatterbot/ext/sqlalchemy_app/models.py,sha256=pjU4e2BUSitw_IAkrk4iFQ9pZRU35y5MomvX7aiBFCw,2492
50
51
  chatterbot/logic/__init__.py,sha256=28-5swBCPfSVMl8xB5C8frOKZ2oj28rQfenbd9E4r-4,531
51
- chatterbot/logic/best_match.py,sha256=iueuuK6WTTywqskwC1CuWD2uHgA65Hz30h8tce_H1bU,4619
52
+ chatterbot/logic/best_match.py,sha256=8TNW0uZ_Uq-XPfaZUMUZDVH6KzDT65j59xblxQBv-dQ,4820
52
53
  chatterbot/logic/logic_adapter.py,sha256=5kNEirh5fiF5hhSMFXD7bIkKwXHmrSsSS4qDm-6xry0,4694
53
54
  chatterbot/logic/mathematical_evaluation.py,sha256=GPDKUwNFajERof2R-MkPGi2jJRP-rKAGm_f0V9JHDHE,2282
54
- chatterbot/logic/specific_response.py,sha256=_VeJaa3kun0J7cVzLOlTYK1tBpth0B6UWms7QwtcNpY,1082
55
+ chatterbot/logic/specific_response.py,sha256=o17YIeu9DzucO8MXMP3kwNIBb1b8br60bbAhSE7AZWc,2386
55
56
  chatterbot/logic/time_adapter.py,sha256=mxdoQGeC5IjREH4PU5iHYOIPEvnYnzgysocR8xMYWXc,2406
56
- chatterbot/logic/unit_conversion.py,sha256=DT50HHE3njUo_ttDSU8S-fwBylarhDF3l_McRLSX6Ic,5823
57
- chatterbot/storage/__init__.py,sha256=IymIHfeisvULQzUYsQSiUBbWIZ1m5EzyMVI082tTw5w,369
58
- chatterbot/storage/django_storage.py,sha256=b_hJkBm0ZNgBB16HjJaNYVFEPs0AApRjOZpuiGNDaXk,6990
59
- chatterbot/storage/mongodb.py,sha256=s6rzn0m_eu4kkXeb80vVCyHyZrdrVW_Zf8PlttUHQlk,8962
60
- chatterbot/storage/sql_storage.py,sha256=X3PKKYcS4tiBWmuvxNMTLxK0shUQlchW0UPB1Mb1rqI,13144
61
- chatterbot/storage/storage_adapter.py,sha256=QwY3cGVpZLxkmww0OnPGZbdOykuOZT7WSKYHq84TgI0,5956
62
- ChatterBot-1.2.1.dist-info/LICENSE,sha256=5b04U8mi0wp5gJMYlKi49EalnD9Q2nwY_6UEI_Avgu4,1476
63
- ChatterBot-1.2.1.dist-info/METADATA,sha256=dF7H-ZhaTdjCYSDFhsChT8h38fFQfykFmXvB6s1v1n0,8311
64
- ChatterBot-1.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
65
- ChatterBot-1.2.1.dist-info/top_level.txt,sha256=W2TzAbAJ-eBXTIKZZhVlkrh87msJNmBQpyhkrHqjSrE,11
66
- ChatterBot-1.2.1.dist-info/RECORD,,
57
+ chatterbot/logic/unit_conversion.py,sha256=-ENMLqZqtZx0riUi0guda2oJECST0M7pZG4cSIv3ieM,5898
58
+ chatterbot/storage/__init__.py,sha256=ADw0WQe0YKr1UIDQLaxwf0mHDnuKW_CSzgz11K4TM-4,465
59
+ chatterbot/storage/django_storage.py,sha256=S5S4GipD7FyNJy4RWu5-S8sLPuSJIObwTtqTpnJu-ok,6159
60
+ chatterbot/storage/mongodb.py,sha256=Ozvdvcjb3LGZxcvbSQGzwP9VloYQbmsa2FaKunFpMyU,7934
61
+ chatterbot/storage/redis.py,sha256=FKROrzZ-7WXZ8ZoK0dKmTDdS45TxL04XOSeu0p3Jrak,12675
62
+ chatterbot/storage/sql_storage.py,sha256=VVYZvclG_74IN-MrG0edc-RQ2gUO6gRQyCWWSO0MmCk,13082
63
+ chatterbot/storage/storage_adapter.py,sha256=fvyb-qNiB0HMJ0siVMCWUIY--6d-C47N1_kKZVFZAv4,6110
64
+ chatterbot-1.2.3.dist-info/LICENSE,sha256=5b04U8mi0wp5gJMYlKi49EalnD9Q2nwY_6UEI_Avgu4,1476
65
+ chatterbot-1.2.3.dist-info/METADATA,sha256=xnofLrmf6knmhcwBVcodzvxpZQ-eb4tbLB970dXQG8I,8503
66
+ chatterbot-1.2.3.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
67
+ chatterbot-1.2.3.dist-info/top_level.txt,sha256=W2TzAbAJ-eBXTIKZZhVlkrh87msJNmBQpyhkrHqjSrE,11
68
+ chatterbot-1.2.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5