Skip to content

Commit 8a47532

Browse files
committed
disclaimer as footer
1 parent 55f939f commit 8a47532

3 files changed

Lines changed: 65 additions & 18 deletions

File tree

.chainlit/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ github = "https://github.com/reactome/reactome_chatbot/issues"
7474

7575
# Specify a Javascript file that can be used to customize the user interface.
7676
# The Javascript file can be served from the public directory.
77-
# custom_js = "/public/test.js"
77+
custom_js = "/public/custom.js"
7878

7979
# Specify a custom meta image url.
8080
# custom_meta_image_url = "https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"

config_default.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,6 @@ usage_limits:
1616

1717
messages:
1818

19-
disclaimer-guests:
20-
message: |-
21-
_**Disclaimer:** Our chatbot uses AI to assist you. Responses are generated automatically and may not always be accurate. Do not share sensitive, personal or confidential information. For more information, please click on the “Readme” icon at the top-right of this window._
22-
recipients:
23-
- guests
24-
trigger:
25-
event: on_chat_start
26-
27-
disclaimer-logged_in:
28-
message: |-
29-
_**Disclaimer:** Our chatbot uses AI to assist you. Responses are generated automatically and may not always be accurate. Do not share sensitive, personal or confidential information. For more information, please click on the “Readme” icon at the top-right of this window._
30-
recipients:
31-
- logged_in
32-
trigger:
33-
event: on_chat_start
34-
freq_max: 1w
35-
3619
welcome:
3720
message: |-
3821
Welcome to {chat_profile}, your interactive chatbot for exploring **[Reactome](https://reactome.org/)**!

public/custom.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Replace the contents of the Chainlit watermark/footer
3+
*/
4+
(function () {
5+
const CUSTOM_FOOTER_HTML = `
6+
<div class="text-xs text-muted-foreground text-center">
7+
<span>
8+
<em>
9+
<strong>Disclaimer:</strong>
10+
Our chatbot uses AI to assist you.
11+
Responses are generated automatically and may not always be accurate.
12+
Do not share sensitive, personal or confidential information.
13+
For more information, please click on the “Readme” icon at the top-right of this window.
14+
</em>
15+
</span>
16+
</div>
17+
`.trim();
18+
19+
const WATERMARK_SELECTOR = 'a.watermark';
20+
const APPLIED_ATTR = 'data-custom-watermark';
21+
22+
function replaceFooterContents(root = document) {
23+
const nodes = root instanceof Element
24+
? root.querySelectorAll(WATERMARK_SELECTOR)
25+
: document.querySelectorAll(WATERMARK_SELECTOR);
26+
27+
nodes.forEach((el) => {
28+
if (!(el instanceof HTMLElement)) return;
29+
if (el.getAttribute(APPLIED_ATTR) === '1') return;
30+
31+
el.innerHTML = CUSTOM_FOOTER_HTML;
32+
33+
// disable the link behaviour
34+
el.removeAttribute('href');
35+
el.removeAttribute('target');
36+
el.style.pointerEvents = 'none';
37+
38+
el.setAttribute(APPLIED_ATTR, '1');
39+
});
40+
}
41+
42+
// Initial run (in case the element is already present).
43+
if (document.readyState === 'loading') {
44+
document.addEventListener('DOMContentLoaded', () => replaceFooterContents(document));
45+
} else {
46+
replaceFooterContents(document);
47+
}
48+
49+
// Re-apply on future UI updates (SPA re-renders).
50+
const mo = new MutationObserver((mutations) => {
51+
for (const m of mutations) {
52+
for (const node of m.addedNodes) {
53+
if (node instanceof Element) {
54+
// If the watermark itself is added or its parent subtree changes, update.
55+
if (node.matches?.(WATERMARK_SELECTOR) || node.querySelector?.(WATERMARK_SELECTOR)) {
56+
replaceFooterContents(node);
57+
}
58+
}
59+
}
60+
}
61+
});
62+
63+
mo.observe(document.documentElement, { childList: true, subtree: true });
64+
})();

0 commit comments

Comments
 (0)