diff --git a/docs/make.jl b/docs/make.jl index 9b3e451c2..fd10b2015 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -21,7 +21,14 @@ makedocs(; canonical = "https://reactivebayes.github.io/RxInfer.jl", edit_link = "main", warn_outdated = true, - assets = String["assets/theme.css", "assets/header.css", "assets/header.js"], + assets = [ + "assets/theme.css", + "assets/header.css", + "assets/header.js", + asset("https://www.gstatic.com/dialogflow-console/fast/df-messenger/prod/v1/themes/df-messenger-default.css"), + asset("https://www.gstatic.com/dialogflow-console/fast/df-messenger/prod/v1/df-messenger.js"), + "assets/chat.js" + ], description = "Julia package for automated Bayesian inference on a factor graph with reactive message passing", footer = "Created in [BIASlab](https://biaslab.github.io/), maintained by [ReactiveBayes](https://github.com/ReactiveBayes), powered by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) and the [Julia Programming Language](https://julialang.org/)." ), @@ -37,12 +44,7 @@ makedocs(; "Inference customization" => ["Defining a custom node and rules" => "manuals/customization/custom-node.md", "Inference results postprocessing" => "manuals/customization/postprocess.md"], "Debugging" => "manuals/debugging.md", "Migration from v2 to v3" => "manuals/migration-guide-v2-v3.md", - "Sharp bits of RxInfer" => [ - "Overview" => "manuals/sharpbits/overview.md", - "Rule Not Found Error" => "manuals/sharpbits/rule-not-found.md", - "Stack Overflow in Message Computations" => "manuals/sharpbits/stack-overflow-inference.md", - "Using `=` instead of `:=` for deterministic nodes" => "manuals/sharpbits/usage-colon-equality.md" - ] + "Sharp bits of RxInfer" => ["Overview" => "manuals/sharpbits/overview.md", "Rule Not Found Error" => "manuals/sharpbits/rule-not-found.md", "Stack Overflow in Message Computations" => "manuals/sharpbits/stack-overflow-inference.md", "Using `=` instead of `:=` for deterministic nodes" => "manuals/sharpbits/usage-colon-equality.md"] ], "Library" => [ "Model construction" => "library/model-construction.md", diff --git a/docs/src/assets/chat.js b/docs/src/assets/chat.js new file mode 100644 index 000000000..49fb4d055 --- /dev/null +++ b/docs/src/assets/chat.js @@ -0,0 +1,92 @@ +// In docs/src/assets/chat-widget.js +document.addEventListener('DOMContentLoaded', function() { + const messenger = document.createElement('df-messenger'); + messenger.setAttribute('project-id', 'synthetic-shape-442012-s9'); + messenger.setAttribute('agent-id', '94fb46c1-e089-404f-8e0f-4478927e5755'); + messenger.setAttribute('language-code', 'en'); + messenger.setAttribute('max-query-length', '-1'); + + const chatBubble = document.createElement('df-messenger-chat-bubble'); + chatBubble.setAttribute('chat-title', 'RxInfer Documentation Chatbot'); + chatBubble.setAttribute('chat-subtitle', ` + Ask questions about RxInfer Documentation + `); + chatBubble.setAttribute('chat-title-icon', 'https://reactivebayes.github.io/RxInfer.jl/stable/assets/ld-rxinfer.png'); + messenger.appendChild(chatBubble); + + document.body.appendChild(messenger); + + const desiredWidth = 720; + + // Function to update chat window width + const updateChatWidth = () => { + const maxWidth = desiredWidth; + const padding = 32; // 16px padding on each side + const availableWidth = Math.min(window.innerWidth - padding, maxWidth); + + style.textContent = ` + df-messenger { + z-index: 999; + position: fixed; + bottom: 16px; + right: 16px; + --df-messenger-font-family: 'PT Mono', system-ui, -apple-system, sans-serif; + --df-messenger-primary-color: rgb(22, 87, 152); + --df-messenger-focus-color: rgb(22, 87, 152); + --df-messenger-chat-window-width: ${availableWidth}px; + --df-messenger-chat-window-offset: 64px; + --df-messenger-titlebar-icon-width: 64px; + --df-messenger-titlebar-icon-height: 64px; + --df-messenger-titlebar-icon-padding: 0 24px 0 0; + } + `; + }; + + // Add styles using documented properties + const style = document.createElement('style'); + updateChatWidth(); // Initial width setting + document.head.appendChild(style); + + // Update width on window resize + window.addEventListener('resize', updateChatWidth); + + // Wait for custom element to be defined + customElements.whenDefined('df-messenger').then(() => { + setTimeout(() => { + const chatWrapper = chatBubble.shadowRoot?.querySelector('.chat-wrapper'); + console.log(chatWrapper); + if (chatWrapper) { + const footer = document.createElement('div'); + const updateFooterWidth = () => { + const maxWidth = desiredWidth; + const padding = 32; + const availableWidth = Math.min(window.innerWidth - padding, maxWidth); + footer.style.cssText = ` + font-size: 11px; + color: #6B7280; + background: #ffffff; + width: ${availableWidth + 2}px; + border-radius: 0 0 4px 4px; + `; + }; + + updateFooterWidth(); // Initial footer width + window.addEventListener('resize', updateFooterWidth); + + const footerText = document.createElement('div'); + footerText.style.cssText = ` + padding: 8px 16px; + line-height: 1.4; + `; + footerText.innerHTML = ` + Responses are automatically generated and may not be accurate. + Please open an issue if you find any inaccuracies. + Powered by Gemini. + Sponsored by Lazy Dynamics. + `; + footer.appendChild(footerText); + chatWrapper.appendChild(footer); + } + }, 10); + }); +}); diff --git a/docs/src/assets/ld-rxinfer.png b/docs/src/assets/ld-rxinfer.png new file mode 100644 index 000000000..d6f9222f2 Binary files /dev/null and b/docs/src/assets/ld-rxinfer.png differ