Skip to content

Commit 441e5e4

Browse files
authored
docs: add deep thinking to AI assistant (medusajs#13770)
* docs: add deep thinking to AI assistant * add disabled styling
1 parent 415d130 commit 441e5e4

File tree

4 files changed

+57
-26
lines changed

4 files changed

+57
-26
lines changed

www/packages/docs-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
"dependencies": {
6060
"@emotion/is-prop-valid": "^1.3.1",
61-
"@kapaai/react-sdk": "^0.3.0",
61+
"@kapaai/react-sdk": "^0.9.0",
6262
"@medusajs/icons": "2.10.3",
6363
"@medusajs/ui": "4.0.23",
6464
"@next/third-parties": "15.3.5",

www/packages/docs-ui/src/components/AiAssistant/ChatWindow/Input/index.tsx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { useEffect, useMemo, useRef } from "react"
22
import clsx from "clsx"
3-
import { ArrowUpCircleSolid } from "@medusajs/icons"
3+
import { ArrowUpCircleSolid, LightBulb, LightBulbSolid } from "@medusajs/icons"
44
import { useAiAssistant, useIsBrowser } from "../../../../providers"
5-
import { useChat } from "@kapaai/react-sdk"
5+
import { useChat, useDeepThinking } from "@kapaai/react-sdk"
66
import { useAiAssistantChatNavigation } from "../../../../hooks"
7+
import { Tooltip } from "../../../Tooltip"
78

89
type AiAssistantChatWindowInputProps = {
910
chatWindowRef: React.RefObject<HTMLDivElement | null>
@@ -15,6 +16,7 @@ export const AiAssistantChatWindowInput = ({
1516
const { chatOpened, inputRef, loading, setChatOpened, isCaptchaLoaded } =
1617
useAiAssistant()
1718
const { submitQuery, conversation } = useChat()
19+
const { active, toggle } = useDeepThinking()
1820
const { isBrowser } = useIsBrowser()
1921
const { searchQuery, searchQueryType } = useMemo(() => {
2022
if (!isBrowser) {
@@ -156,13 +158,43 @@ export const AiAssistantChatWindowInput = ({
156158
placeholder="Ask me a question about Medusa..."
157159
disabled={loading}
158160
/>
159-
<div className="flex items-center justify-end">
161+
<div className="flex items-center justify-between">
162+
<Tooltip
163+
tooltipChildren={
164+
<span>
165+
Get better answers for complex questions.
166+
<br />
167+
Results may take up to 1 minute.
168+
</span>
169+
}
170+
>
171+
<button
172+
onClick={toggle}
173+
disabled={loading}
174+
className={clsx(
175+
"txt-compact-xsmall-plus appearance-none transition-colors flex items-center gap-docs_0.25 px-docs_0.5 py-docs_0.25 rounded-docs_sm",
176+
!active &&
177+
"bg-transparent hover:bg-medusa-button-transparent-hover text-medusa-fg-muted hover:text-medusa-fg-subtle",
178+
active &&
179+
"bg-medusa-tag-orange-bg hover:bg-medusa-tag-orange-bg-hover text-medusa-tag-orange-text",
180+
loading && "cursor-not-allowed opacity-50"
181+
)}
182+
type="button"
183+
>
184+
{!active && <LightBulb />}
185+
{active && (
186+
<LightBulbSolid className="text-medusa-tag-orange-icon" />
187+
)}
188+
Deep Thinking
189+
</button>
190+
</Tooltip>
160191
<button
161192
className={clsx(
162193
"appearance-none p-0 text-medusa-fg-base disabled:text-medusa-fg-disabled",
163194
"transition-colors"
164195
)}
165196
disabled={!question || loading || !isCaptchaLoaded}
197+
type="submit"
166198
>
167199
<ArrowUpCircleSolid />
168200
</button>

www/packages/docs-ui/src/components/Button/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type ButtonProps = {
1616
className?: string
1717
buttonType?: ButtonType
1818
buttonRef?: React.LegacyRef<HTMLButtonElement>
19+
type?: "button" | "submit" | "reset"
1920
} & React.HTMLAttributes<HTMLButtonElement>
2021

2122
export const Button = ({

www/yarn.lock

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -790,32 +790,30 @@ __metadata:
790790
languageName: node
791791
linkType: hard
792792

793-
"@fingerprintjs/fingerprintjs-pro-react@npm:^2.6.3":
794-
version: 2.7.0
795-
resolution: "@fingerprintjs/fingerprintjs-pro-react@npm:2.7.0"
793+
"@fingerprintjs/fingerprintjs-pro-react@npm:^2.7.0":
794+
version: 2.7.1
795+
resolution: "@fingerprintjs/fingerprintjs-pro-react@npm:2.7.1"
796796
dependencies:
797-
"@fingerprintjs/fingerprintjs-pro-spa": ^1.3.2
797+
"@fingerprintjs/fingerprintjs-pro-spa": ^1.3.3
798798
fast-deep-equal: 3.1.3
799-
checksum: 8892e325885ba4d5a10ffc48764dc016dcff73c1fc356c9aff245fbdb48c17b5b99c74ad280017f6739d0f035e505ece0006ad74116fc947bcb7c6042591d6a5
799+
checksum: b815f631be86cc9ff86be4f50b365b041af23e635661c44e37953d8c4c2e3add627c4314a38bf72176ccbd8c608b417da97b7396bf58cda5973121fafcb81efc
800800
languageName: node
801801
linkType: hard
802802

803-
"@fingerprintjs/fingerprintjs-pro-spa@npm:^1.3.2":
804-
version: 1.3.2
805-
resolution: "@fingerprintjs/fingerprintjs-pro-spa@npm:1.3.2"
803+
"@fingerprintjs/fingerprintjs-pro-spa@npm:^1.3.3":
804+
version: 1.3.3
805+
resolution: "@fingerprintjs/fingerprintjs-pro-spa@npm:1.3.3"
806806
dependencies:
807-
"@fingerprintjs/fingerprintjs-pro": ^3.11.0
807+
"@fingerprintjs/fingerprintjs-pro": ^3.12.0
808808
tslib: ^2.7.0
809-
checksum: a53fb7be19fe04dcb9705bcbd790ff7a411864ab031044193292046cbd63ec1c80672ed67a5b5326eef0320af35f21853281294fca471148c25ceb1aca24b555
809+
checksum: 1049753761ed0fe25085b874529d9dfa377326fb82aa6e1c09cdfacd2d059b5d8b5f5e27d1c56ed3b08ea39ce36de5746e793d3294eba124d8f91af7ca394b76
810810
languageName: node
811811
linkType: hard
812812

813-
"@fingerprintjs/fingerprintjs-pro@npm:^3.11.0":
814-
version: 3.11.10
815-
resolution: "@fingerprintjs/fingerprintjs-pro@npm:3.11.10"
816-
dependencies:
817-
tslib: ^2.4.1
818-
checksum: 981cdeabaf63da38062ed4864193d13df44aa5bd2654135d75866d4f4d06e60cceb8711973d2d881820ebb05b5a05d7ee0ffba1b0990c2f13ae5b5e72e0a3b71
813+
"@fingerprintjs/fingerprintjs-pro@npm:^3.12.0":
814+
version: 3.12.3
815+
resolution: "@fingerprintjs/fingerprintjs-pro@npm:3.12.3"
816+
checksum: 660790bbf6cecfdf00f00b93cab60385d6bc959f46c3d31933dc92585afd16e3c48e8300e8df925ba774ffa66b6e1fb7d909fea2c44fd1608c62aefed4791871
819817
languageName: node
820818
linkType: hard
821819

@@ -1263,19 +1261,19 @@ __metadata:
12631261
languageName: node
12641262
linkType: hard
12651263

1266-
"@kapaai/react-sdk@npm:^0.3.0":
1267-
version: 0.3.0
1268-
resolution: "@kapaai/react-sdk@npm:0.3.0"
1264+
"@kapaai/react-sdk@npm:^0.9.0":
1265+
version: 0.9.0
1266+
resolution: "@kapaai/react-sdk@npm:0.9.0"
12691267
dependencies:
1270-
"@fingerprintjs/fingerprintjs-pro-react": ^2.6.3
1268+
"@fingerprintjs/fingerprintjs-pro-react": ^2.7.0
12711269
"@hcaptcha/react-hcaptcha": ^1.12.0
12721270
"@tanstack/react-query": ^5.74.3
12731271
js-cookie: ^3.0.5
12741272
tldts: ^7.0.7
12751273
peerDependencies:
12761274
react: ">=17.0.0"
12771275
react-dom: ">=17.0.0"
1278-
checksum: 5e68cbebcbe74940e1894e8b1d6e93f78dce45b7571556846ee07fbb8d91774b8fc60162548477aecddfb038caec2601f55a5ebcc34d7f91098f53aec5efe9ce
1276+
checksum: d3fc9de9b2b5e176d2905ef75d012b130320be281cab236154e8faac8b5e0cc574c4b23c07da7ffd2bdccbf2ea281828ec222c2d80d6214092ec4295896f5c09
12791277
languageName: node
12801278
linkType: hard
12811279

@@ -7175,7 +7173,7 @@ __metadata:
71757173
resolution: "docs-ui@workspace:packages/docs-ui"
71767174
dependencies:
71777175
"@emotion/is-prop-valid": ^1.3.1
7178-
"@kapaai/react-sdk": ^0.3.0
7176+
"@kapaai/react-sdk": ^0.9.0
71797177
"@medusajs/icons": 2.10.3
71807178
"@medusajs/ui": 4.0.23
71817179
"@next/third-parties": 15.3.5

0 commit comments

Comments
 (0)