From 37c2ed18dd623a7908b222d8448b3e65fa048aa9 Mon Sep 17 00:00:00 2001
From: Laurie Voss <github@seldo.com>
Date: Wed, 13 Nov 2024 14:02:30 -0800
Subject: [PATCH] Swap out Mendable for RunLLM (#16947)

---
 docs/docs/javascript/mendablesearch.js | 65 --------------------------
 docs/docs/javascript/runllm.js         | 20 ++++++++
 docs/mkdocs.yml                        |  2 +-
 3 files changed, 21 insertions(+), 66 deletions(-)
 delete mode 100644 docs/docs/javascript/mendablesearch.js
 create mode 100644 docs/docs/javascript/runllm.js

diff --git a/docs/docs/javascript/mendablesearch.js b/docs/docs/javascript/mendablesearch.js
deleted file mode 100644
index cf162a9050..0000000000
--- a/docs/docs/javascript/mendablesearch.js
+++ /dev/null
@@ -1,65 +0,0 @@
-document.addEventListener("DOMContentLoaded", () => {
-  // Load the external dependencies
-  function loadScript(src, onLoadCallback) {
-    const script = document.createElement("script");
-    script.src = src;
-    script.onload = onLoadCallback;
-    document.head.appendChild(script);
-  }
-
-  function createRootElement() {
-    const rootElement = document.createElement("div");
-    rootElement.id = "my-component-root";
-    document.body.appendChild(rootElement);
-    return rootElement;
-  }
-
-  function initializeMendable() {
-    const rootElement = createRootElement();
-    const { MendableFloatingButton } = Mendable;
-
-    const icon = React.createElement(
-      "p",
-      {
-        style: {
-          color: "#ffffff",
-          fontSize: "40px",
-          width: "48px",
-          height: "48px",
-          margin: "0px",
-          padding: "0px",
-          display: "flex",
-          alignItems: "center",
-          justifyContent: "center",
-        },
-      },
-      "🦙",
-    );
-
-    const mendableFloatingButton = React.createElement(MendableFloatingButton, {
-      style: { darkMode: false, accentColor: "#010810" },
-      floatingButtonStyle: { color: "#ffffff", backgroundColor: "#010810" },
-      anon_key: "d0fb5ab6-ae6c-49dc-8d38-5115fe8e4755", // Public ANON key, ok to be public
-      messageSettings: {
-        openSourcesInNewTab: false,
-        prettySources: true,
-      },
-      showSimpleSearch: true,
-      icon: icon,
-    });
-
-    ReactDOM.render(mendableFloatingButton, rootElement);
-  }
-
-  loadScript("https://unpkg.com/react@17/umd/react.production.min.js", () => {
-    loadScript(
-      "https://unpkg.com/react-dom@17/umd/react-dom.production.min.js",
-      () => {
-        loadScript(
-          "https://unpkg.com/@mendable/search@0.0.206/dist/umd/mendable.min.js",
-          initializeMendable,
-        );
-      },
-    );
-  });
-});
diff --git a/docs/docs/javascript/runllm.js b/docs/docs/javascript/runllm.js
new file mode 100644
index 0000000000..e904e63aba
--- /dev/null
+++ b/docs/docs/javascript/runllm.js
@@ -0,0 +1,20 @@
+document.addEventListener("DOMContentLoaded", function () {
+    var script = document.createElement("script");
+    script.defer = true;
+    script.type = "module";
+    script.id = "runllm-widget-script";
+    script.src =
+      "https://widget.runllm.com";
+    script.setAttribute("runllm-preset", "mkdocs");
+    script.setAttribute("runllm-server-address", "https://api.runllm.com");
+    script.setAttribute("runllm-assistant-id", "209");
+    script.setAttribute("runllm-position", "BOTTOM_RIGHT");
+    script.setAttribute("runllm-keyboard-shortcut", "Mod+j");
+    script.setAttribute(
+      "runllm-slack-community-url",
+      "https://discord.com/invite/eN6D2HQ4aX"
+    );
+    script.setAttribute("runllm-name", "RunLLM");
+
+    document.head.appendChild(script);
+  });
diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml
index aa269bd5c1..8dc70caacb 100644
--- a/docs/mkdocs.yml
+++ b/docs/mkdocs.yml
@@ -6,7 +6,7 @@ extra_css:
   - css/style.css
   - css/algolia.css
 extra_javascript:
-  - javascript/mendablesearch.js
+  - javascript/runllm.js
   - javascript/algolia.js
 markdown_extensions:
   - attr_list
-- 
GitLab