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

Clear Messages Button? #270

Open
elfar opened this issue Sep 18, 2024 · 3 comments
Open

Clear Messages Button? #270

elfar opened this issue Sep 18, 2024 · 3 comments

Comments

@elfar
Copy link

elfar commented Sep 18, 2024

Hi, first of all congrats on excellent project, big fan!

I was just wondering, along the lines of the buttons "images" or "microphone" etc. Is there a way to place a "cleanup | reset | empty history" type of a button in the same location as the other buttons you support? Or is the current solution only to place the reset button outside of the deep-chat element and have it call clearMessages?

@quietdreamr
Copy link

Hi @elfar,

I managed to add a clear button through a somewhat hacky way:

clearChat() {
    deepchat.clearMessages();
}

injectClearButton() {
    const clearButtonEl = new clearButton()
    clearButtonEl.addEventListener("click", clearChat.bind(this))
    clearButtonEl.setAttribute("disabled", "true")

    const shadowRoot = this.deepChatEl?.shadowRoot
    const targetElement = shadowRoot?.querySelector("#text-input-container")
    targetElement?.prepend(clearButtonEl)
}

image

It's of course not ideal, but gets the job done in my case. I hope it does so for you too.

@elfar
Copy link
Author

elfar commented Sep 26, 2024

Looks better than the one I placed on the outside of the box, thanks for sharing 🙏

@yeungxh
Copy link

yeungxh commented Oct 17, 2024

I'm using vue2, also looking a way to add the clear button.

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

No branches or pull requests

3 participants