Skip to content

Commit 609f09e

Browse files
committed
Fixed the race condition for the loading of the chat assistant
1 parent 8ac1fd5 commit 609f09e

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

docs/_templates/base.html

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22

33
{%- block scripts %}
44
{{ super() }}
5-
5+
66
<!-- OSA Chat Widget (HED Assistant)
77
Privacy Note: This widget sends page content to an external AI service when
88
allowPageContext is enabled. The widget provides contextual help for HEDTools documentation.
99
Data sent: Page text content, user questions
1010
Service: OSA Chat Widget (osa-demo.pages.dev)
1111
-->
12-
<script src="https://osa-demo.pages.dev/osa-chat-widget.js"
13-
crossorigin="anonymous"
14-
defer></script>
15-
<script defer>
16-
// Initialize widget after script loads (defer ensures non-blocking)
17-
if (window.OSAChatWidget) {
18-
OSAChatWidget.setConfig({
19-
communityId: 'hed',
20-
title: 'HED Assistant',
21-
initialMessage: 'Hi! I can help with using the Python HEDTools. What would you like to know?',
22-
placeholder: 'Ask about HED...',
23-
suggestedQuestions: [
24-
'How do I install the Python HEDTools?',
25-
'How do I validate a HED string using the Python HEDTools?',
26-
'How do I run the HEDTools hedpy command line tool?',
27-
'What tools are available?'
28-
],
29-
widgetInstructions: 'User is on the Python HEDTools documentation most likely looking for how to use these tools',
30-
showExperimentalBadge: true,
31-
allowPageContext: true,
32-
pageContextDefaultEnabled: true
33-
});
34-
}
12+
<script>
13+
// Define config before the widget script loads
14+
window.osaChatConfig = {
15+
communityId: 'hed',
16+
title: 'HED Assistant',
17+
initialMessage: 'Questions about HED or Python HEDTools? Ask me!',
18+
placeholder: 'Questions about Python HEDTools?',
19+
suggestedQuestions: [
20+
'How do I install the Python HEDTools?',
21+
'How do I validate a HED string using the Python HEDTools?',
22+
'How do I run the HEDTools hedpy command line tool?',
23+
'What tools are available?'
24+
],
25+
widgetInstructions: 'User is on the Python HEDTools documentation most likely looking for how to use these tools',
26+
showExperimentalBadge: true,
27+
allowPageContext: true,
28+
pageContextDefaultEnabled: true
29+
};
3530
</script>
31+
<script src="https://osa-demo.pages.dev/osa-chat-widget.js"
32+
crossorigin="anonymous"
33+
defer
34+
onload="window.OSAChatWidget && window.OSAChatWidget.setConfig(window.osaChatConfig)"></script>
3635
{%- endblock scripts %}
36+

0 commit comments

Comments
 (0)