Skip to content

Commit

Permalink
update backend to support mds
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed May 27, 2024
1 parent e7306ba commit 5d8477b
Show file tree
Hide file tree
Showing 18 changed files with 185 additions and 348 deletions.
2 changes: 1 addition & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dataSourceManagement"
],
"optionalPlugins": [
"securityDashboards"
"securityDashboards","dataSource", "dataSourceManagement"
],
"configPath": [
"assistant"
Expand Down
7 changes: 5 additions & 2 deletions public/chat_flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EuiResizableContainer } from '@elastic/eui';
import cs from 'classnames';
import React, { useMemo, useRef } from 'react';
import { useObservable } from 'react-use';
import { BehaviorSubject } from 'rxjs';
import { useChatContext } from './contexts/chat_context';
import { ChatPage } from './tabs/chat/chat_page';
import { ChatWindowHeader } from './tabs/chat_window_header';
Expand All @@ -25,8 +26,10 @@ export const ChatFlyout = (props: ChatFlyoutProps) => {
const chatContext = useChatContext();
const chatHistoryPageLoadedRef = useRef(false);
const core = useCore();
// TODO: use DataSourceService to replace
const selectedDS = useObservable(
core.services.setupDeps.dataSourceManagement.dataSourceSelection.getSelection$()
core.services.setupDeps?.dataSourceManagement?.dataSourceSelection?.getSelection$() ??
new BehaviorSubject(new Map())
);
const currentDS = useMemo(() => {
return selectedDS?.values().next().value;
Expand Down Expand Up @@ -97,7 +100,7 @@ export const ChatFlyout = (props: ChatFlyoutProps) => {
<ChatWindowHeader />
<div>
Data Source:
{currentDS?.[0].label}
{currentDS?.[0]?.label}
</div>
</div>

Expand Down
309 changes: 0 additions & 309 deletions public/components/feedback_modal.tsx

This file was deleted.

4 changes: 3 additions & 1 deletion public/contexts/core_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {
useOpenSearchDashboards,
} from '../../../../src/plugins/opensearch_dashboards_react/public';
import { AssistantPluginStartDependencies, AssistantPluginSetupDependencies } from '../types';
import { ConversationLoadService, ConversationsService } from '../services';
import { ConversationLoadService, ConversationsService, DataSourceService } from '../services';

export interface AssistantServices extends Required<OpenSearchDashboardsServices> {
setupDeps: AssistantPluginSetupDependencies;
startDeps: AssistantPluginStartDependencies;
conversationLoad: ConversationLoadService;
conversations: ConversationsService;
// This service is maintained in chatbot instead of dataSource exported from core plugin.
dataSource: DataSourceService;
}

export const useCore: () => OpenSearchDashboardsReactContextValue<
Expand Down
3 changes: 3 additions & 0 deletions public/hooks/use_chat_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const useChatActions = (): AssistantActions => {
...(!chatContext.conversationId && { messages: chatState.messages }), // include all previous messages for new chats
input,
}),
query: core.services.dataSource.getDataSourceQuery(),
});
if (abortController.signal.aborted) return;
// Refresh history list after new conversation created if new conversation saved and history list page visible
Expand Down Expand Up @@ -162,6 +163,7 @@ export const useChatActions = (): AssistantActions => {
// abort agent execution
await core.services.http.post(`${ASSISTANT_API.ABORT_AGENT_EXECUTION}`, {
body: JSON.stringify({ conversationId }),
query: core.services.dataSource.getDataSourceQuery(),
});
}
};
Expand All @@ -178,6 +180,7 @@ export const useChatActions = (): AssistantActions => {
conversationId: chatContext.conversationId,
interactionId,
}),
query: core.services.dataSource.getDataSourceQuery(),
});

if (abortController.signal.aborted) {
Expand Down
1 change: 1 addition & 0 deletions public/hooks/use_conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const useDeleteConversation = () => {
return core.services.http
.delete(`${ASSISTANT_API.CONVERSATION}/${conversationId}`, {
signal: abortControllerRef.current.signal,
query: core.services.dataSource.getDataSourceQuery(),
})
.then((payload) => {
dispatch({ type: 'success', payload });
Expand Down
Loading

0 comments on commit 5d8477b

Please sign in to comment.