-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joshua Li <[email protected]> Co-authored-by: Paul Sebastian <[email protected]>
- Loading branch information
1 parent
d9bd287
commit d4d8dbc
Showing
54 changed files
with
4,001 additions
and
1,745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
const QUERY_ASSIST_API_PREFIX = '/api/observability/query_assist'; | ||
export const QUERY_ASSIST_API = { | ||
GENERATE_PPL: `${QUERY_ASSIST_API_PREFIX}/generate_ppl`, | ||
SUMMARIZE: `${QUERY_ASSIST_API_PREFIX}/summarize`, | ||
}; | ||
|
||
export const ML_COMMONS_API_PREFIX = '/_plugins/_ml'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,826 changes: 1,016 additions & 810 deletions
1,826
public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiCodeEditor, EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui'; | ||
import React, { useEffect, useMemo } from 'react'; | ||
import { coreRefs } from '../../../framework/core_refs'; | ||
import { QueryAssistInput } from '../../event_analytics/explorer/query_assist/input'; | ||
import { useFetchEvents } from '../../event_analytics/hooks/use_fetch_events'; | ||
|
||
export function QueryArea({ | ||
tabId, | ||
handleQueryChange, | ||
handleTimePickerChange, | ||
handleTimeRangePickerRefresh, | ||
runQuery, | ||
tempQuery, | ||
setNeedsUpdate, | ||
setFillRun, | ||
selectedIndex, | ||
nlqInput, | ||
setNlqInput, | ||
pplService, | ||
}: any) { | ||
const requestParams = { tabId }; | ||
const { getAvailableFields } = useFetchEvents({ | ||
pplService, | ||
requestParams, | ||
}); | ||
|
||
// use effect that sets the editor text and populates sidebar field for a particular index upon initialization | ||
const memoizedGetAvailableFields = useMemo(() => getAvailableFields, []); | ||
const memoizedHandleQueryChange = useMemo(() => handleQueryChange, []); | ||
useEffect(() => { | ||
const indexQuery = `source = ${selectedIndex[0].label}`; | ||
memoizedHandleQueryChange(indexQuery); | ||
memoizedGetAvailableFields(indexQuery); | ||
}, [selectedIndex, memoizedGetAvailableFields, memoizedHandleQueryChange]); | ||
|
||
return ( | ||
<EuiPanel paddingSize="m"> | ||
<EuiFlexGroup gutterSize="m" direction="column"> | ||
<EuiFlexItem> | ||
<EuiCodeEditor | ||
theme="textmate" | ||
width="100%" | ||
height="4rem" | ||
showPrintMargin={false} | ||
setOptions={{ | ||
fontSize: '14px', | ||
}} | ||
aria-label="Code Editor" | ||
onChange={(query) => { | ||
handleQueryChange(query); | ||
// query is considered updated when the last run query is not the same as whats in the editor | ||
// setUpdatedQuery(runQuery !== query); | ||
setNeedsUpdate(runQuery !== query); | ||
}} | ||
onFocus={() => setFillRun(true)} | ||
onBlur={() => setFillRun(false)} | ||
value={tempQuery} | ||
wrapEnabled={true} | ||
/> | ||
</EuiFlexItem> | ||
{coreRefs.queryAssistEnabled && ( | ||
<EuiFlexItem> | ||
<QueryAssistInput | ||
tabId={tabId} | ||
handleTimePickerChange={handleTimePickerChange} | ||
handleQueryChange={handleQueryChange} | ||
handleTimeRangePickerRefresh={handleTimeRangePickerRefresh} | ||
setNeedsUpdate={setNeedsUpdate} | ||
selectedIndex={selectedIndex} | ||
nlqInput={nlqInput} | ||
setNlqInput={setNlqInput} | ||
/> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
} |
111 changes: 111 additions & 0 deletions
111
public/components/common/search/query_assist_summarization.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
EuiAccordion, | ||
EuiBadge, | ||
EuiCallOut, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiIcon, | ||
EuiLink, | ||
EuiMarkdownFormat, | ||
EuiPanel, | ||
EuiSpacer, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
import React from 'react'; | ||
import chatLogo from '../../datasources/icons/query-assistant-logo.svg'; | ||
|
||
export function QueryAssistSummarization({ | ||
queryAssistantSummarization, | ||
setNlqInput, | ||
showFlyout, | ||
}: any) { | ||
return ( | ||
<EuiPanel> | ||
<EuiAccordion | ||
id="summarization-accordion" | ||
buttonContent="AI Insights" | ||
initialIsOpen | ||
isLoading={queryAssistantSummarization?.summaryLoading ?? false} | ||
isLoadingMessage="Loading summary.." | ||
extraAction={ | ||
<EuiFlexGroup direction="row" alignItems="center" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiText color="subdued"> | ||
<small>Generated by Opensearch Assistant</small> | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type={chatLogo} size="l" /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
> | ||
{queryAssistantSummarization?.summary?.length > 0 && ( | ||
<> | ||
<EuiSpacer size="m" /> | ||
{queryAssistantSummarization?.isPPLError ? ( | ||
<> | ||
<EuiCallOut title="There was an error" color="danger" iconType="alert"> | ||
<EuiMarkdownFormat>{queryAssistantSummarization.summary}</EuiMarkdownFormat> | ||
</EuiCallOut> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexGroup wrap gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="s">Suggestions:</EuiText> | ||
</EuiFlexItem> | ||
{queryAssistantSummarization.suggestedQuestions.map((question) => ( | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge | ||
color="hollow" | ||
iconType="chatRight" | ||
iconSide="left" | ||
onClick={() => setNlqInput(question)} | ||
onClickAriaLabel="Set input to the suggested question" | ||
> | ||
{question} | ||
</EuiBadge> | ||
</EuiFlexItem> | ||
))} | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge | ||
color="hollow" | ||
iconType="questionInCircle" | ||
iconSide="left" | ||
onClick={showFlyout} | ||
onClickAriaLabel="Show PPL documentation" | ||
> | ||
PPL Documentation | ||
</EuiBadge> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
) : ( | ||
<EuiPanel color="subdued" style={{ marginLeft: 16, marginRight: 16 }}> | ||
<EuiMarkdownFormat>{queryAssistantSummarization.summary}</EuiMarkdownFormat> | ||
</EuiPanel> | ||
)} | ||
<EuiSpacer size="m" /> | ||
<EuiText color="subdued"> | ||
<small> | ||
The OpenSearch Assistant may produce inaccurate information. Verify all information | ||
before using it in any environment or workload. Share feedback via{' '} | ||
<EuiLink href="https://forum.opensearch.org/t/feedback-opensearch-assistant/16741"> | ||
Forum | ||
</EuiLink>{' '} | ||
or{' '} | ||
<EuiLink href="https://opensearch.slack.com/channels/assistant-feedback"> | ||
Slack | ||
</EuiLink> | ||
</small> | ||
</EuiText> | ||
</> | ||
)} | ||
</EuiAccordion> | ||
</EuiPanel> | ||
); | ||
} |
Oops, something went wrong.