Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge feature/explorer-query-assistant to main #1325

Merged
merged 94 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
1263c81
implement query area section w/ assistant bar and w/out functionality
paulstn Nov 6, 2023
ff84089
repace refresh button with run
paulstn Nov 6, 2023
fe860fd
initial poc to add assistant dependency
joshuali925 Sep 14, 2023
92fae57
port changes for using assistant in event analytics
joshuali925 Sep 27, 2023
7eb7a17
enable feedback button on log explorer
joshuali925 Oct 31, 2023
c6b7546
update layout of llm input in log explorer
joshuali925 Nov 2, 2023
e571c18
update default question for query assist
joshuali925 Nov 3, 2023
fb433db
add username and tenant to feedback
joshuali925 Nov 3, 2023
3ff0555
try to remove error toast
joshuali925 Nov 4, 2023
60b36ad
use form for NLQ input field
joshuali925 Nov 4, 2023
39690a5
small ui changes
paulstn Nov 10, 2023
5ac1e9e
reintroduced refresh
paulstn Nov 10, 2023
fdbfc91
disable timepicker
paulstn Nov 10, 2023
f117297
fixed data grid render issue
paulstn Nov 11, 2023
037a679
code editor wrap
paulstn Nov 11, 2023
efa1b94
empty query row
paulstn Nov 11, 2023
14f7897
add summarization UI in event analytics
joshuali925 Nov 11, 2023
7fba5e6
add error summary in event analytics
joshuali925 Nov 11, 2023
c33662e
handle summarization errors
joshuali925 Nov 13, 2023
aa599ce
send PPL query for summarization
joshuali925 Nov 13, 2023
0ea7f02
lang picker and lang flyout changes
paulstn Nov 13, 2023
efce177
update summarization api call
joshuali925 Nov 13, 2023
310e293
moved summary down to results
paulstn Nov 14, 2023
73a6ea0
auto select first data source
paulstn Nov 14, 2023
d6be998
actually set data source thru redux
paulstn Nov 14, 2023
4e77592
use constants
paulstn Nov 14, 2023
ea53f74
complete mimic of timepicker refresh button
paulstn Nov 14, 2023
5203c2a
modified query gen buttons
paulstn Nov 14, 2023
4ab2c62
changed positioning of lang and index selector and refactored
paulstn Nov 15, 2023
f48aa3f
ui set for query assistant bar
paulstn Nov 15, 2023
7d7bafc
moved summary above events
paulstn Nov 15, 2023
0bbdfec
working generate buttons
paulstn Nov 15, 2023
ff761f8
change chat logo
paulstn Nov 16, 2023
f832b5e
update summarization api and UI to show suggestions as badges
joshuali925 Nov 16, 2023
d60a83c
url params fill olly question
paulstn Nov 16, 2023
c490725
switched buttons around and added mail link
paulstn Nov 16, 2023
08e3d5a
fixed url parsing
paulstn Nov 16, 2023
8478d90
toast error messages for generate query button
paulstn Nov 16, 2023
b3e4f8f
url redirect will run question, and functional working version of sug…
paulstn Nov 16, 2023
e25338d
stop crashes when index has no suggested questions
paulstn Nov 16, 2023
e83f2b5
bump to 2.11.0 for easier build
joshuali925 Nov 16, 2023
b0410a1
only include hardcoded indexes
paulstn Nov 16, 2023
58778db
empty index no more crashing
paulstn Nov 16, 2023
8a6ad6e
reset results and summary after run or generate buttons pressed
paulstn Nov 17, 2023
7e2c019
url redirection auto run happens after props set, and moved buttons a…
paulstn Nov 17, 2023
16f5cdd
disable focus trap on suggestions
joshuali925 Nov 17, 2023
449a3d8
fixed run button issue not updating to most recent query
paulstn Nov 17, 2023
acad902
reuse explorerData for summarization
joshuali925 Nov 18, 2023
361d13e
only summarize when calling "Generate and run"
joshuali925 Nov 18, 2023
6fddaaf
update links and redirections
paulstn Nov 20, 2023
64f734c
changed some hardcoded indices
paulstn Nov 20, 2023
cfdd9cb
do not pass extra data to summarization api
joshuali925 Nov 20, 2023
b6d846e
hide ai insights if no summary is there or loading
paulstn Nov 21, 2023
8c1fde4
set the order_date to be default timestamp
paulstn Nov 21, 2023
d3268f1
fixing app analytics page crash
mengweieric Nov 21, 2023
1b2390b
re-enable datepicker for app analytics
mengweieric Nov 21, 2023
c10a64f
remove live button for olly
mengweieric Nov 21, 2023
c18d85f
fixing startTime and endTime states in search.tsx
sejli Nov 21, 2023
d7c53c4
add support for catching timestamp in redirection url
mengweieric Nov 21, 2023
678ed90
send PPL query for summarization
joshuali925 Nov 22, 2023
0193c49
truncate summarize API call to prevent going over maxPayloadBytes
joshuali925 Nov 27, 2023
1ab96ba
add error message when response code is 429
joshuali925 Nov 28, 2023
0c5a45b
set default text in editor upon index start and change
paulstn Nov 28, 2023
6ccb122
populate sidebar fields depending on selected index
paulstn Nov 28, 2023
536c865
pass in pplService and use explicit dependency array
paulstn Nov 29, 2023
448f48e
send the correct error message when summarizing response
joshuali925 Nov 29, 2023
19ad058
reducing sidebar requests and fixing hit counter + patterns bug
sejli Nov 30, 2023
4ce20d1
removing summary when no data is returned
sejli Dec 5, 2023
7154529
Merge pull request #1287 from sejli/no-results-no-summary
paulstn Dec 5, 2023
3f6bf5e
initial state and empty state change
paulstn Dec 7, 2023
1e2ce06
refactor query assist input
joshuali925 Dec 18, 2023
b530365
replace langchain API with ml-commons agents for query assist
joshuali925 Dec 21, 2023
6b17329
read agent id from config
joshuali925 Dec 21, 2023
36a82fc
Merge branch 'main' into feature/explorer-query-assistant
joshuali925 Dec 21, 2023
247283b
fix config errors
joshuali925 Dec 21, 2023
c4436d3
add unit tests for util functions
joshuali925 Dec 22, 2023
070620d
add `observability.query_assist.enabled` config and hide query assist…
joshuali925 Dec 22, 2023
b343245
add more unit tests
joshuali925 Dec 22, 2023
592e09a
small linting complaints
paulstn Jan 10, 2024
8a6132d
Merge branch 'main' of https://github.com/opensearch-project/dashboar…
paulstn Jan 10, 2024
4b5f787
fix issue with query assist enabled blocking timerange past 15 mins
paulstn Jan 10, 2024
5e4e7f5
refactor query assist summarization
paulstn Jan 10, 2024
b6e6993
reintroduce old autocorrect feature for non-query-assistant users, fi…
paulstn Jan 10, 2024
dd9a98a
Various fixes and changes (#1350)
paulstn Jan 10, 2024
0483ca9
Merge branch 'feature/explorer-query-assistant' of https://github.com…
paulstn Jan 10, 2024
4a249a6
move strings to constants file
paulstn Jan 10, 2024
8f96c7e
update app analytics snapshots
paulstn Jan 10, 2024
7822356
update event analytics tests and snapshots
paulstn Jan 10, 2024
f9f1dfe
re-enable reigsterMessageParser method
paulstn Jan 10, 2024
4539a8b
change default time range to be 40 years
paulstn Jan 12, 2024
09bf7a2
Merge branch 'feature/explorer-query-assistant' of https://github.com…
paulstn Jan 12, 2024
ff0d2ca
Merge pull request #1355 from paulstn/feature-explorer-query-assistant
paulstn Jan 12, 2024
fd41414
Merge branch 'main' of https://github.com/opensearch-project/dashboar…
paulstn Jan 12, 2024
7d0227f
Merge pull request #1356 from paulstn/feature-explorer-query-assistant
paulstn Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/constants/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

export const DATA_SOURCE_NAME_URL_PARAM_KEY = 'datasourceName';
export const DATA_SOURCE_TYPE_URL_PARAM_KEY = 'datasourceType';
export const OLLY_QUESTION_URL_PARAM_KEY = 'olly_q';
export const INDEX_URL_PARAM_KEY = 'indexPattern';
export const DEFAULT_DATA_SOURCE_TYPE = 'DEFAULT_INDEX_PATTERNS';
export const DEFAULT_DATA_SOURCE_NAME = 'Default cluster';
export const DEFAULT_DATA_SOURCE_OBSERVABILITY_DISPLAY_NAME = 'OpenSearch';
Expand Down
1 change: 1 addition & 0 deletions common/constants/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const RAW_QUERY = 'rawQuery';
export const FINAL_QUERY = 'finalQuery';
export const SELECTED_DATE_RANGE = 'selectedDateRange';
export const INDEX = 'index';
export const OLLY_QUERY_ASSISTANT = 'ollyQueryAssistant';
export const SELECTED_PATTERN_FIELD = 'selectedPatternField';
export const PATTERN_REGEX = 'patternRegex';
export const FILTERED_PATTERN = 'filteredPattern';
Expand Down
12 changes: 12 additions & 0 deletions common/constants/query_assist.ts
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';
3 changes: 3 additions & 0 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,6 @@ export const S3_DATASOURCE_TYPE = 'S3_DATASOURCE';
export const ASYNC_QUERY_SESSION_ID = 'async-query-session-id';

export const DIRECT_DUMMY_QUERY = 'select 1';

export const QUERY_ASSISTANT_FIXED_START_TIME = 'now-40y';
export const QUERY_ASSISTANT_FIXED_END_TIME = 'now';
8 changes: 3 additions & 5 deletions opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"urlForwarding",
"visualizations"
],
"optionalPlugins": [
"managementOverview",
"assistantDashboards"
]
}
"optionalPlugins": ["managementOverview", "assistantDashboards"],
"configPath": ["observability"]
}
Binary file removed public/.DS_Store
Binary file not shown.
12 changes: 6 additions & 6 deletions public/components/common/live_tail/live_tail_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

//Define pop over interval options for live tail button in your plugin
// Define pop over interval options for live tail button in your plugin

import { EuiButton } from "@elastic/eui";
import React, { useMemo } from "react";
import { LiveTailProps } from "common/types/explorer";
import { EuiButton } from '@elastic/eui';
import React, { useMemo } from 'react';
import { LiveTailProps } from 'common/types/explorer';

//Live Tail Button
// Live Tail Button
export const LiveTailButton = ({
isLiveTailOn,
isLiveTailPopoverOpen,
Expand All @@ -20,7 +20,7 @@ export const LiveTailButton = ({
const liveButton = useMemo(() => {
return (
<EuiButton
iconType={isLiveTailOn ? "stop" : "play"}
iconType={isLiveTailOn ? 'stop' : 'clock'}
iconSide="left"
onClick={() => setIsLiveTailPopoverOpen(!isLiveTailPopoverOpen)}
data-test-subj={dataTestSubj}
Expand Down
58 changes: 45 additions & 13 deletions public/components/common/search/date_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,57 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiSuperDatePicker } from '@elastic/eui';
import { IDatePickerProps } from './search';
import { EuiSuperDatePicker, EuiToolTip } from '@elastic/eui';
import React, { useEffect } from 'react';
import { uiSettingsService } from '../../../../common/utils';
import { coreRefs } from '../../../framework/core_refs';
import { IDatePickerProps } from './search';
import {
QUERY_ASSISTANT_FIXED_END_TIME,
QUERY_ASSISTANT_FIXED_START_TIME,
} from '../../../../common/constants/shared';

export function DatePicker(props: IDatePickerProps) {
const { startTime, endTime, handleTimePickerChange, handleTimeRangePickerRefresh } = props;
const {
startTime,
endTime,
handleTimePickerChange,
handleTimeRangePickerRefresh,
isAppAnalytics,
} = props;

const handleTimeChange = (e: any) => handleTimePickerChange([e.start, e.end]);
const allowTimeChanging = !coreRefs.queryAssistEnabled || isAppAnalytics;

// set the time range to be 40 years rather than the standard 15 minutes if using query assistant
useEffect(() => {
if (!allowTimeChanging) {
handleTimePickerChange([QUERY_ASSISTANT_FIXED_START_TIME, QUERY_ASSISTANT_FIXED_END_TIME]);
}
}, []);

return (
<EuiSuperDatePicker
data-test-subj="pplSearchDatePicker"
start={startTime}
end={endTime}
dateFormat={uiSettingsService.get('dateFormat')}
onTimeChange={handleTimeChange}
onRefresh={handleTimeRangePickerRefresh}
className="osdQueryBar__datePicker"
/>
<>
<EuiToolTip
position="bottom"
content={
allowTimeChanging
? false
: 'Date range has been disabled to accomodate timerange of all datasets'
}
>
<EuiSuperDatePicker
data-test-subj="pplSearchDatePicker"
start={allowTimeChanging ? startTime : QUERY_ASSISTANT_FIXED_START_TIME}
end={allowTimeChanging ? endTime : QUERY_ASSISTANT_FIXED_END_TIME}
dateFormat={uiSettingsService.get('dateFormat')}
onTimeChange={handleTimeChange}
onRefresh={handleTimeRangePickerRefresh}
className="osdQueryBar__datePicker"
showUpdateButton={false}
isDisabled={!allowTimeChanging}
/>
</EuiToolTip>
</>
);
}
81 changes: 81 additions & 0 deletions public/components/common/search/query_area.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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,
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}
handleQueryChange={handleQueryChange}
handleTimeRangePickerRefresh={handleTimeRangePickerRefresh}
setNeedsUpdate={setNeedsUpdate}
selectedIndex={selectedIndex}
nlqInput={nlqInput}
setNlqInput={setNlqInput}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiPanel>
);
}
111 changes: 111 additions & 0 deletions public/components/common/search/query_assist_summarization.tsx
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 chatLogo from '../../datasources/icons/query-assistant-logo.svg';
import React from 'react';

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>
);
}
Loading
Loading