-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add sqlite pragma settings to sql_storage.py - change distinct to aggregate in mongodb.py #916
Changes from 8 commits
af76b8c
99b14ed
957a970
25a2f1a
29cd3fe
9c202a8
16beccd
a86df43
17f0a1b
01a43cc
73295bc
f844bbf
a58f3e0
bfbadc4
5066b2c
0ba10a6
0346efd
11272e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,9 @@ def __init__(self, **kwargs): | |
# Use the default host and port | ||
self.client = MongoClient(self.database_uri) | ||
|
||
# Increase the sort buffer to 42M | ||
self.client.admin.command({'setParameter': 1, 'internalQueryExecMaxBlockingSortBytes': 44040192}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like tests are failing after this change;
|
||
|
||
# Specify the name of the database | ||
self.database = self.client[self.database_name] | ||
|
||
|
@@ -262,7 +265,7 @@ def get_latest_response(self, conversation_id): | |
|
||
return self.mongo_to_object(statements[-2]) | ||
|
||
def add_to_converation(self, conversation_id, statement, response): | ||
def add_to_conversation(self, conversation_id, statement, response): | ||
""" | ||
Add the statement and response to the conversation. | ||
""" | ||
|
@@ -331,23 +334,26 @@ def get_response_statements(self): | |
in_response_to field. Otherwise, the logic adapter may find a closest | ||
matching statement that does not have a known response. | ||
""" | ||
response_query = self.statements.distinct('in_response_to.text') | ||
response_query = self.statements.aggregate([{'$group': {'_id': '$in_response_to.text'}}]) | ||
|
||
responses = [] | ||
for r in response_query: | ||
try: | ||
responses.extend(r['_id']) | ||
except TypeError: | ||
pass | ||
|
||
_statement_query = { | ||
'text': { | ||
'$in': response_query | ||
'$in': responses | ||
} | ||
} | ||
|
||
_statement_query.update(self.base_query.value()) | ||
|
||
statement_query = self.statements.find(_statement_query) | ||
|
||
statement_objects = [] | ||
|
||
for statement in list(statement_query): | ||
statement_objects.append(self.mongo_to_object(statement)) | ||
|
||
return statement_objects | ||
|
||
def drop(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
output_adapter='chatterbot.output.TerminalAdapter' | ||
) | ||
|
||
DEFAULT_SESSION_ID = bot.default_session.id | ||
DEFAULT_SESSION_ID = bot.default_conversation_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could also rephrase to DEFAULT_CONVERSATION_ID There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
|
||
|
||
def get_feedback(): | ||
|
@@ -56,7 +56,7 @@ def get_feedback(): | |
|
||
# Update the conversation history for the bot | ||
# It is important that this happens last, after the learning step | ||
bot.storage.add_to_converation(bot.default_session, statement, response) | ||
bot.storage.add_to_conversation(bot.default_session, statement, response) | ||
|
||
# Press ctrl-c or ctrl-d on the keyboard to exit | ||
except (KeyboardInterrupt, EOFError, SystemExit): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
bot.train("chatterbot.corpus.english") | ||
|
||
DEFAULT_SESSION_ID = bot.default_session.id | ||
DEFAULT_SESSION_ID = bot.default_conversation_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could also rephrase to DEFAULT_CONVERSATION_ID There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
|
||
|
||
def get_feedback(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍