|
1
|
"use client" |
|
2
|
|
|
3
|
import React from "react" |
|
4
|
import { SearchHitGroupName } from "../../Search/Hits/GroupName" |
|
5
|
import { SearchSuggestionItem } from "../../Search/Suggestions/Item" |
|
6
|
import { useChat } from "@kapaai/react-sdk" |
|
7
|
import { Link } from "../../Link" |
|
8
|
import { useSiteConfig } from "../../../providers/SiteConfig" |
|
9
|
import { useAiAssistant } from "../../../providers/AiAssistant" |
|
10
|
|
|
11
|
type AiAssistantSuggestionsProps = React.AllHTMLAttributes<HTMLDivElement> |
|
12
|
|
|
13
|
export const AiAssistantSuggestions = (props: AiAssistantSuggestionsProps) => { |
|
14
|
const { |
|
15
|
config: { baseUrl }, |
|
16
|
} = useSiteConfig() |
|
17
|
const { submitQuery } = useChat() |
|
18
|
const { suggestions, hideAiToolsMessage } = useAiAssistant() |
|
19
|
|
|
20
|
return ( |
|
21
|
<div {...props}> |
|
22
|
{!hideAiToolsMessage && ( |
|
23
|
<span className="text-medusa-fg-muted text-compact-small px-docs_0.5 py-docs_0.75 block"> |
|
24
|
For assistance in your development, use{" "} |
|
25
|
<Link |
|
26
|
href={`${baseUrl}/learn/introduction/build-with-llms-ai#claude-code-plugins`} |
|
27
|
variant="content" |
|
28
|
> |
|
29
|
Claude Code Plugins |
|
30
|
</Link>{" "} |
|
31
|
or{" "} |
|
32
|
<Link |
|
33
|
href={`${baseUrl}/learn/introduction/build-with-llms-ai/docs-mcp-server`} |
|
34
|
variant="content" |
|
35
|
> |
|
36
|
Docs MCP server |
|
37
|
</Link>{" "} |
|
38
|
in Cursor, VSCode, etc... |
|
39
|
</span> |
|
40
|
)} |
|
41
|
{suggestions.map((suggestion, index) => ( |
|
42
|
<React.Fragment key={index}> |
|
43
|
<SearchHitGroupName name={suggestion.title} /> |
|
44
|
{suggestion.items.map((item, itemIndex) => ( |
|
45
|
<SearchSuggestionItem |
|
46
|
onClick={() => { |
|
47
|
submitQuery(item) |
|
48
|
}} |
|
49
|
key={itemIndex} |
|
50
|
tabIndex={itemIndex} |
|
51
|
> |
|
52
|
{item} |
|
53
|
</SearchSuggestionItem> |
|
54
|
))} |
|
55
|
</React.Fragment> |
|
56
|
))} |
|
57
|
</div> |
|
58
|
) |
|
59
|
} |