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.
- chatterbot/__init__.py +1 -1
- chatterbot/chatterbot.py +41 -8
- chatterbot/comparisons.py +32 -15
- chatterbot/logic/best_match.py +42 -35
- chatterbot/logic/specific_response.py +52 -9
- chatterbot/logic/unit_conversion.py +4 -3
- chatterbot/response_selection.py +1 -1
- chatterbot/search.py +65 -17
- chatterbot/storage/__init__.py +2 -0
- chatterbot/storage/django_storage.py +13 -23
- chatterbot/storage/mongodb.py +7 -26
- chatterbot/storage/redis.py +390 -0
- chatterbot/storage/sql_storage.py +77 -68
- chatterbot/storage/storage_adapter.py +9 -7
- chatterbot/trainers.py +3 -3
- chatterbot/vectorstores.py +74 -0
- {ChatterBot-1.2.1.dist-info → chatterbot-1.2.3.dist-info}/METADATA +9 -3
- {ChatterBot-1.2.1.dist-info → chatterbot-1.2.3.dist-info}/RECORD +21 -19
- {ChatterBot-1.2.1.dist-info → chatterbot-1.2.3.dist-info}/WHEEL +1 -1
- {ChatterBot-1.2.1.dist-info → chatterbot-1.2.3.dist-info}/LICENSE +0 -0
- {ChatterBot-1.2.1.dist-info → chatterbot-1.2.3.dist-info}/top_level.txt +0 -0
@@ -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
|
-
|
21
|
-
|
22
|
-
|
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.
|
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.
|
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.
|
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.
|
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
|

|
63
70
|
|
@@ -70,7 +77,6 @@ to be trained to speak any language.
|
|
70
77
|
|
71
78
|
[](https://pypi.python.org/pypi/chatterbot/)
|
72
79
|
[](https://www.python.org/downloads/release/python-360/)
|
73
|
-
[](https://docs.djangoproject.com/en/2.1/releases/2.0/)
|
74
80
|
[](https://coveralls.io/r/gunthercox/ChatterBot)
|
75
81
|
[](https://codeclimate.com/github/gunthercox/ChatterBot)
|
76
82
|
[](https://gitter.im/chatterbot/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
chatterbot/__init__.py,sha256=
|
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=
|
5
|
-
chatterbot/comparisons.py,sha256=
|
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=
|
16
|
-
chatterbot/search.py,sha256=
|
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=
|
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=
|
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=
|
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
|
57
|
-
chatterbot/storage/__init__.py,sha256=
|
58
|
-
chatterbot/storage/django_storage.py,sha256=
|
59
|
-
chatterbot/storage/mongodb.py,sha256=
|
60
|
-
chatterbot/storage/
|
61
|
-
chatterbot/storage/
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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,,
|
File without changes
|
File without changes
|