-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow chat items to be deleted #120
Changes from all commits
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 |
---|---|---|
|
@@ -48,17 +48,15 @@ def __init__(self, engine=None, batch_size=100, save_every=1): | |
self._last_save = time.time() | ||
|
||
def commit(self): | ||
with Session(self.engine) as session: | ||
try: | ||
try: | ||
with Session(self.engine) as session: | ||
session.add_all(self.batch) | ||
session.commit() | ||
logger.debug('added %s items', len(self.batch)) | ||
self.batch = [] | ||
except SQLAlchemyError as e: | ||
logger.warn('Got error when trying to commit to database: %s', e) | ||
session.rollback() | ||
raise e | ||
self.batch = [] | ||
self._last_save = time.time() | ||
except SQLAlchemyError as e: | ||
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. there's an interesting Heisenbug with sessions being dropped - this won't fix it, but at least won't break the chat when it happens. It only happens when the chatbot isn't used for a long period of time, which hopefully shouldn't be an issue once things start being used? |
||
logger.warn('Got error when trying to commit to database: %s', e) | ||
|
||
def add(self, *items): | ||
"""Add the provided items to the database, commiting them if needed.""" | ||
|
@@ -69,6 +67,4 @@ def add(self, *items): | |
|
||
def __del__(self): | ||
logger.debug('cleaning up session') | ||
if self.session: | ||
self.commit() | ||
self.session.close() | ||
self.commit() |
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.
Make sure the LLM only sees non deleted items