Skip to content

Commit 553ad57

Browse files
authored
Rework AskAI suggestions (#2031)
* Rework AskAI suggestions * Run prettier
1 parent 592e7d9 commit 553ad57

File tree

2 files changed

+44
-51
lines changed

2 files changed

+44
-51
lines changed

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/AskAiSuggestions.tsx

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,66 @@ import { useChatActions } from './chat.store'
33
import { EuiButton, useEuiTheme } from '@elastic/eui'
44
import { css } from '@emotion/react'
55
import * as React from 'react'
6-
7-
const buttonStyles = css`
8-
border: none;
9-
& > span {
10-
justify-content: flex-start;
11-
}
12-
`
6+
import { useMemo } from 'react'
137

148
export interface AskAiSuggestion {
159
question: string
1610
}
1711

18-
interface Props {
19-
suggestions: Set<AskAiSuggestion>
20-
}
12+
// Comprehensive list of AI suggestion questions
13+
const ALL_SUGGESTIONS: AskAiSuggestion[] = [
14+
{ question: 'How do I set up a data stream in Elasticsearch?' },
15+
{ question: 'What are the best practices for indexing performance?' },
16+
{ question: 'How can I create a dashboard in Kibana?' },
17+
{ question: 'What is the difference between a keyword and text field?' },
18+
{ question: 'How do I configure machine learning jobs?' },
19+
{ question: 'What are aggregations and how do I use them?' },
20+
{ question: 'How do I set up Elasticsearch security and authentication?' },
21+
{ question: 'What are the different types of Elasticsearch queries?' },
22+
{ question: 'How do I monitor cluster health and performance?' },
23+
{
24+
question:
25+
'What is the Elastic Stack and how do the components work together?',
26+
},
27+
{ question: 'How do I create and manage Elasticsearch indices?' },
28+
{ question: 'What are the best practices for Elasticsearch mapping?' },
29+
{ question: 'How do I set up log shipping with Beats?' },
30+
{ question: 'What is APM and how do I use it for application monitoring?' },
31+
{ question: 'How do I create custom visualizations in Kibana?' },
32+
{ question: 'What are Elasticsearch snapshots and how do I use them?' },
33+
{ question: 'How do I configure cross-cluster search?' },
34+
{
35+
question:
36+
'What are the different Elasticsearch node types and their roles?',
37+
},
38+
]
2139

22-
export const AskAiSuggestions = (props: Props) => {
40+
export const AskAiSuggestions = () => {
2341
const { submitQuestion } = useChatActions()
2442
const { setModalMode } = useModalActions()
2543
const { euiTheme } = useEuiTheme()
2644

27-
const dynamicButtonStyles = css`
28-
${buttonStyles}
29-
svg {
30-
color: ${euiTheme.colors.textSubdued};
31-
}
32-
`
45+
// Randomly select 3 questions from the comprehensive list
46+
const selectedSuggestions = useMemo(() => {
47+
// Shuffle the array and take first 3
48+
const shuffled = [...ALL_SUGGESTIONS].sort(() => Math.random() - 0.5)
49+
return shuffled.slice(0, 3)
50+
}, [])
3351

3452
return (
3553
<ul>
36-
{Array.from(props.suggestions).map((suggestion) => (
37-
<li key={suggestion.question}>
54+
{selectedSuggestions.map((suggestion) => (
55+
<li
56+
key={suggestion.question}
57+
css={css`
58+
margin-bottom: ${euiTheme.size.s};
59+
`}
60+
>
3861
<EuiButton
3962
iconType="newChat"
40-
color="text"
63+
color="primary"
4164
fullWidth
4265
size="s"
43-
css={dynamicButtonStyles}
4466
onClick={() => {
4567
submitQuestion(suggestion.question)
4668
setModalMode('askAi')

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/Chat.tsx

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -150,36 +150,7 @@ export const Chat = () => {
150150
<h3>Try asking me:</h3>
151151
</EuiTitle>
152152
<EuiSpacer size="s" />
153-
<AskAiSuggestions
154-
suggestions={
155-
new Set([
156-
{
157-
question:
158-
'How do I set up a data stream in Elasticsearch?',
159-
},
160-
{
161-
question:
162-
'What are the best practices for indexing performance?',
163-
},
164-
{
165-
question:
166-
'How can I create a dashboard in Kibana?',
167-
},
168-
{
169-
question:
170-
'What is the difference between a keyword and text field?',
171-
},
172-
{
173-
question:
174-
'How do I configure machine learning jobs?',
175-
},
176-
{
177-
question:
178-
'What are aggregations and how do I use them?',
179-
},
180-
])
181-
}
182-
/>
153+
<AskAiSuggestions />
183154
</>
184155
}
185156
/>

0 commit comments

Comments
 (0)