Skip to content

Commit

Permalink
Replace AI widget with kapa (#32222)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 335b5a795708420a00298fa74d73165eb10e9620
  • Loading branch information
ikhare authored and Convex, Inc. committed Dec 13, 2024
1 parent e24f7b4 commit 465fd6c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 34 deletions.
1 change: 1 addition & 0 deletions docs/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"jetbrains",
"Jetpack",
"JWKS",
"kapa",
"keyof",
"kotlinx",
"LangChain",
Expand Down
13 changes: 13 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ const config = {
defer: true,
"data-domain": "docs.convex.dev",
},
{
src: "https://widget.kapa.ai/kapa-widget.bundle.js",
"data-button-hide": "true",
"data-modal-override-open-id": "kapa-ai-chat-button",
"data-website-id": "a20c0988-f33e-452b-9174-5045a58b965d",
"data-project-name": "Convex",
"data-project-color": "#141414",
"data-project-logo":
"https://img.stackshare.io/service/41143/default_f1d33b63d360437ba28c8ac981dd68d7d2478b22.png",
"data-user-analytics-fingerprint-enabled": "true",
"data-search-mode-enabled": "true",
async: true,
},
],
};

Expand Down
41 changes: 7 additions & 34 deletions src/components/ConvexAiChat/ConvexAiChat.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import React from "react";
import { ConvexAiChat as ConvexAiChatComponent } from "convex-ai-chat/react";
import "convex-ai-chat/react/styles-docs.css";

export function ConvexAiChat() {
const {
siteConfig: {
customFields: { convexUrl },
},
} = useDocusaurusContext();

const configuredConvexUrl = getConvexURLFromQueryParam() ?? convexUrl;

return configuredConvexUrl !== undefined ? (
<ConvexAiChatComponent
convexUrl={configuredConvexUrl}
infoMessage={
"Convex AI Bot can make mistakes. " +
"When in doubt, reach out to our human team on Discord."
}
welcomeMessage="Hey there, what can I answer about Convex?"
renderTrigger={(onClick) => (
<button className="convex-ai-chat" onClick={onClick}>
<span />
</button>
)}
/>
) : null;
}

function getConvexURLFromQueryParam() {
if (typeof window === "undefined") {
return undefined;
}
const url = window.location.href;
const urlParams = new URLSearchParams(new URL(url).search);
return urlParams.get("chatUrl");
return (
<>
<button className="convex-ai-chat" id="kapa-ai-chat-button">
Ask AI
</button>
</>
);
}
1 change: 1 addition & 0 deletions src/css/ai-chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
font-family: Inter, sans-serif;
margin-left: 0.5rem;
cursor: pointer;
white-space: nowrap;
}

html[data-theme="dark"] .convex-ai-chat {
Expand Down

0 comments on commit 465fd6c

Please sign in to comment.