Skip to content

Commit 5615ca8

Browse files
authored
UI updates, user feedback fixes (#87)
* open links in new tab; fixes #81 * links to reactome.org from /chat ; closes #83 * remove survey, direct to help email; closes #84 * avert KeyError for unused embeddings bundles; fixes #86 * add disclaimers; closes #80 * replace favicon with SVG; fixes #82 * disclaimer as footer
1 parent 8bd10c9 commit 5615ca8

10 files changed

Lines changed: 85 additions & 12 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"

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
data/
12
embeddings/
23
embeddings_bak/
34
csv_files/

bin/chat-fastapi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,17 @@ async def landing_page():
288288
<body>
289289
<div class="container">
290290
<div class="logo">
291-
<img src="https://reactome.org/templates/favourite/images/logo/logo.png" alt="Reactome Logo">
291+
<a href="https://reactome.org" target="_blank">
292+
<img src="https://reactome.org/templates/favourite/images/logo/logo.png" alt="Reactome Logo">
293+
</a>
292294
</div>
293295
<h1>Meet the React-to-Me AI Chatbot!</h1>
294296
<p class="centered-text">Your new guide to Reactome. Whether you're looking for specific genes and pathways or just browsing, our AI Chatbot is here to assist you!</p>
295297
296298
<div class="button-container">
297299
<a class="button" href="$CHAINLIT_URL/chat/guest/" target="_blank">Guest Access</a>
298300
<a class="button" href="$CHAINLIT_URL/chat/personal/" target="_blank">Log In</a>
299-
<a class="button feedback-button" href="https://forms.gle/Rvzb8EA73yZs7wd38" target="_blank">Feedback</a>
301+
<a class="button feedback-button" href="mailto:help@reactome.org" target="_blank">Feedback</a>
300302
</div>
301303
302304
<p class="left-justified">Choose <strong>Guest Access</strong> to try the chatbot out. <strong>Log In</strong> will give an increased query allowance and securely stores your chat history so you can save and continue conversations.</p>

chainlit.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ Explore pathways such as:
3535

3636
Happy exploring with React-to-me!
3737

38+
## _Disclaimer_
39+
40+
_This chatbot uses large language model (LLM) technology to assist with questions about the Reactome Knowledgebase. Responses are generated automatically and may contain inaccuracies, outdated information or speculative language._
41+
42+
_The information you provide may be retained in accordance with Reactome’s AI provider’s retention policy, which is located [here](https://openai.com/enterprise-privacy/). Do not share sensitive, personal or confidential information._
43+
44+
_The chatbot does not substitute for expert curation or peer-reviewed sources and is not a suitable resource for clinical decisions. Users are responsible for validating any output before using it for research, publication, or medical decisions. Any use of this chatbot is subject to Reactome’s [disclaimer](https://reactome.org/about/disclaimer)._

config_default.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@ messages:
1818

1919
welcome:
2020
message: |-
21-
Welcome to {chat_profile}, your interactive chatbot for exploring Reactome!
21+
Welcome to {chat_profile}, your interactive chatbot for exploring **[Reactome](https://reactome.org/)**!
2222
Ask me about biological pathways and processes.
2323
trigger:
2424
event: on_chat_start
2525

26-
survey_message:
27-
message: |-
28-
We hope you're enjoying your experience with React-to-me! We'd love to hear your feedback to make it even better. Please take a few minutes to fill out our [survey](https://forms.gle/Rvzb8EA73yZs7wd38).
29-
trigger:
30-
after_messages: 3
31-
3226
demo-message:
3327
message: |-
3428
Hello!

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+
})();

public/elements/SearchResults.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const SearchResults = () => {
1616
<a
1717
key={result.id}
1818
href={result.url}
19+
target="_blank"
1920
className="flex flex-col items-start gap-2 rounded-lg border p-3 text-left text-sm transition-all hover:bg-accent"
2021
>
2122
<div className="flex w-full flex-col gap-1">

public/favicon.ico

-583 Bytes
Binary file not shown.

public/favicon.svg

Lines changed: 1 addition & 0 deletions
Loading

src/util/embedding_environment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ def get_dict(cls) -> dict[str, Path]:
2727
return cls._get().embeddings
2828

2929
@classmethod
30-
def get_dir(cls, key: str) -> Path:
31-
return EM_ARCHIVE / cls._get().embeddings[key]
30+
def get_dir(cls, key: str) -> Path | None:
31+
if key in cls._get().embeddings:
32+
return EM_ARCHIVE / cls._get().embeddings[key]
33+
else:
34+
return None
3235

3336
@classmethod
3437
def get_model(cls, key: str) -> str:

0 commit comments

Comments
 (0)