Skip to content
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

Merged
merged 2 commits into from
Oct 18, 2023
Merged

Allow chat items to be deleted #120

merged 2 commits into from
Oct 18, 2023

Conversation

mruwnik
Copy link
Collaborator

@mruwnik mruwnik commented Oct 17, 2023

I was uncertain whether to just delete any removed history items and totally forget about them, or to just soft delete them. The hard delete is nice in that it's a lot simpler, but has the downside that it would totally mess up the history which gets logged to the database. I considered having a proper changelog type thingy, which would allow one to recreate the whole session, but decided against it as it would get very complicated. On the other hand, the current logging implementation adds a number saying which interaction this is, based on the history length. An alternative to this would be to always query the database before writing, to get the number of interactions in this session.
I went with a soft delete, as that can be used later on to make an interactive session viewer, which is something I wanted to do anyway, to play about with seeing how different prompts and settings effect things.

image

@@ -175,7 +175,7 @@ def make_memory(settings, history, callbacks):
return_messages=True,
callbacks=callbacks
)
memory.set_messages(history)
memory.set_messages([i for i in history if i.get('role') != 'deleted'])
Copy link
Collaborator Author

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

self._last_save = time.time()
except SQLAlchemyError as e:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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?
An objection can be raised that this will result in interactions not getting logged, which is an issue, but not a pressing one, as this is only for logging purposes, and should only happen if the error occurs and then the worker is shut down - otherwise the interactions will be saved the next time something happens, as they're saved in batches anyway

web/src/components/chat.tsx Outdated Show resolved Hide resolved
@mruwnik mruwnik merged commit 1cd14cd into main Oct 18, 2023
1 check passed
@mruwnik mruwnik deleted the delete-items branch October 18, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants