forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Observability AI Assistant] Create chat (#17)
- Loading branch information
1 parent
74422f9
commit 745d7ee
Showing
38 changed files
with
1,323 additions
and
810 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
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/observability_ai_assistant/public/components/chat/chat_body.stories.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,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ComponentStory } from '@storybook/react'; | ||
import React from 'react'; | ||
import { ChatBody as Component } from './chat_body'; | ||
|
||
export default { | ||
component: Component, | ||
title: 'app/Organisms/ChatBody', | ||
}; | ||
|
||
type ChatBodyProps = React.ComponentProps<typeof Component>; | ||
|
||
const Template: ComponentStory<typeof Component> = (props: ChatBodyProps) => { | ||
return ( | ||
<div style={{ minHeight: 800, display: 'flex' }}> | ||
<Component {...props} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const defaultProps: ChatBodyProps = { | ||
initialConversation: { | ||
'@timestamp': new Date().toISOString(), | ||
conversation: { | ||
title: 'My conversation', | ||
}, | ||
labels: {}, | ||
numeric_labels: {}, | ||
messages: [], | ||
}, | ||
connectors: { | ||
connectors: [ | ||
{ | ||
id: 'foo', | ||
referencedByCount: 1, | ||
actionTypeId: 'foo', | ||
name: 'GPT-v8-ultra', | ||
isPreconfigured: true, | ||
isDeprecated: false, | ||
isSystemAction: false, | ||
}, | ||
], | ||
loading: false, | ||
error: undefined, | ||
selectedConnector: 'foo', | ||
selectConnector: () => {}, | ||
}, | ||
currentUser: { | ||
username: 'elastic', | ||
}, | ||
chat: { | ||
loading: false, | ||
abort: () => {}, | ||
generate: async () => { | ||
return {} as any; | ||
}, | ||
}, | ||
}; | ||
|
||
export const ChatBody = Template.bind({}); | ||
ChatBody.args = defaultProps; |
81 changes: 81 additions & 0 deletions
81
x-pack/plugins/observability_ai_assistant/public/components/chat/chat_body.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,81 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiPanel } from '@elastic/eui'; | ||
import { css } from '@emotion/css'; | ||
import type { AuthenticatedUser } from '@kbn/security-plugin/common'; | ||
import React from 'react'; | ||
import { type ConversationCreateRequest } from '../../../common/types'; | ||
import type { UseChatResult } from '../../hooks/use_chat'; | ||
import type { UseGenAIConnectorsResult } from '../../hooks/use_genai_connectors'; | ||
import { useTimeline } from '../../hooks/use_timeline'; | ||
import { ChatHeader } from './chat_header'; | ||
import { ChatPromptEditor } from './chat_prompt_editor'; | ||
import { ChatTimeline } from './chat_timeline'; | ||
|
||
const containerClassName = css` | ||
max-height: 100%; | ||
`; | ||
|
||
const timelineClassName = css` | ||
overflow-y: auto; | ||
`; | ||
|
||
export function ChatBody({ | ||
initialConversation, | ||
connectors, | ||
currentUser, | ||
chat, | ||
}: { | ||
initialConversation?: ConversationCreateRequest; | ||
connectors: UseGenAIConnectorsResult; | ||
currentUser?: Pick<AuthenticatedUser, 'full_name' | 'username'>; | ||
chat: UseChatResult; | ||
}) { | ||
const timeline = useTimeline({ | ||
initialConversation, | ||
connectors, | ||
currentUser, | ||
chat, | ||
}); | ||
|
||
return ( | ||
<EuiFlexGroup direction="column" gutterSize="none" className={containerClassName}> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel hasBorder={false} hasShadow={false} paddingSize="l"> | ||
<ChatHeader title="foo" connectors={connectors} /> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiHorizontalRule margin="none" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow className={timelineClassName}> | ||
<EuiPanel hasBorder={false} hasShadow={false} paddingSize="l"> | ||
<ChatTimeline | ||
items={timeline.items} | ||
onEdit={timeline.onEdit} | ||
onFeedback={timeline.onFeedback} | ||
onRegenerate={timeline.onRegenerate} | ||
onStopGenerating={timeline.onStopGenerating} | ||
/> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiHorizontalRule margin="none" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel hasBorder={false} hasShadow={false} paddingSize="l"> | ||
<ChatPromptEditor | ||
loading={chat.loading} | ||
disabled={!connectors.selectedConnector} | ||
onSubmit={timeline.onSubmit} | ||
/> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} |
45 changes: 0 additions & 45 deletions
45
x-pack/plugins/observability_ai_assistant/public/components/chat/chat_flyout.stories.tsx
This file was deleted.
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
Oops, something went wrong.