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

Add a watermark parameter to gr.Chatbot that is added to copied text #10756

Open
surak opened this issue Mar 7, 2025 · 3 comments
Open

Add a watermark parameter to gr.Chatbot that is added to copied text #10756

surak opened this issue Mar 7, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@surak
Copy link

surak commented Mar 7, 2025

When a user copies the text generated by the LLM, this triggers the event ChatBot.copy, which is great. But the listener only gives you the copied text, and does not let you modify it.

In order to comply with the EU AI Act, chatbots should give a kind of watermark on generated content. For text, a simple "Generated by AI" somewhere in the text is enough.

I tried something like this:

        def add_ai_tag(message):
            message[0][1] = message[0][1] + "Generated by AI"
            return message
    
        chatbot.copy(add_ai_tag, chatbot, chatbot)

But this changes the text on the chatbot dialogue itself, and not the text being sent to the clipboard, making me believe that Chatbox.copy happens after the copy has happened, or I am clearly doing something silly and I couldn't understand the documentation (which is pretty difficult on the event listeners part).

Any hints are welcome, and an example on the documentation would be super useful (as everyone needs to do that in the EU now).

@abidlabs
Copy link
Member

abidlabs commented Mar 7, 2025

Hi @surak yes it's not possible to modify the clipboard value in the .copy() method. I suppose you could do something like this:

import gradio as gr

value = """
Hi <span style="display:none">Generated by AI</span>
"""

with gr.Blocks() as demo:
    c = gr.Chatbot([(value, value)], show_copy_button=True)

demo.launch()

But we could potentially include add a copy_watermark parameter in gr.Chatbot to get the nicer behavior you described automatically. Can you elaborate more on what the EU AI Act requires or link to a relevant explainer?

@abidlabs abidlabs added enhancement New feature or request pending clarification labels Mar 7, 2025
@surak
Copy link
Author

surak commented Mar 8, 2025

So, the EU AI act states (I can find the exact reference if needed) that all AI generated product should be clearly labeled as so.

In the case of a chatbot, an explanation in the website that the chatbot is AI and not a person is enough. But when you take this chatbot's output out of the website and into somewhere else, you need a "watermark". Think of the little dall-e thing on the lower left corner of their images. But in the case of text, anything saying that the text was generated by AI is enough. It's then up to the user to remove it, which takes the liability to the user and not to the system.

If you need the exact links, I can find them with my lawyer.

@abidlabs abidlabs changed the title Chatbot.copy event to allow change of text before copying it Add a watermark parameter to gr.Chatbot that is added to copied text Mar 8, 2025
@abidlabs
Copy link
Member

abidlabs commented Mar 8, 2025

Cool that's sufficiently clear, we can add this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants