Skip to content

Commit 6e71ea0

Browse files
dbanksdesigndindjarinjsatierian
authored
Adding AIConversation docs (#8116)
* Adding AIConversation docs * fixing build error * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: dindjarinjs <[email protected]> * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: Ian Saultz <[email protected]> * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: Ian Saultz <[email protected]> * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: Ian Saultz <[email protected]> * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: Ian Saultz <[email protected]> * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: Ian Saultz <[email protected]> * Update src/pages/[platform]/ai/conversation/ai-conversation/index.mdx Co-authored-by: Ian Saultz <[email protected]> * updats * chore: bump ui-react lib --------- Co-authored-by: dindjarinjs <[email protected]> Co-authored-by: Ian Saultz <[email protected]>
1 parent 20667e9 commit 6e71ea0

File tree

9 files changed

+532
-18
lines changed

9 files changed

+532
-18
lines changed

cspell.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,8 @@
16141614
"ampx",
16151615
"autodetection",
16161616
"jamba",
1617-
"knowledgebases"
1617+
"knowledgebases",
1618+
"rehype"
16181619
],
16191620
"flagWords": ["hte", "full-stack", "Full-stack", "Full-Stack", "sudo"],
16201621
"patterns": [

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"private": true,
1111
"dependencies": {
1212
"@aws-amplify/amplify-cli-core": "^4.3.9",
13-
"@aws-amplify/ui-react": "^6.3.1",
13+
"@aws-amplify/ui-react": "^6.7.0",
14+
"@aws-amplify/ui-react-ai": "^1.0.0",
1415
"@docsearch/react": "3",
1516
"ajv": "^8.16.0",
1617
"aws-amplify": "^6.0.9",

public/images/user.jpg

39.5 KB
Loading

src/components/AI/index.tsx

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Avatar } from '@aws-amplify/ui-react';
2+
import { ConversationMessage } from '@aws-amplify/ui-react-ai';
3+
import { AmplifyLogo } from '@/components/GlobalNav/components/icons';
4+
5+
export const UserAvatar = () => {
6+
return <Avatar src="/images/user.jpg" />;
7+
};
8+
9+
export const AssistantAvatar = () => {
10+
return (
11+
<Avatar backgroundColor={'primary.20'}>
12+
<AmplifyLogo />
13+
</Avatar>
14+
);
15+
};
16+
17+
export const MESSAGES: ConversationMessage[] = [
18+
{
19+
conversationId: 'foobar',
20+
id: '1',
21+
content: [{ text: 'Hello' }],
22+
role: 'user' as const,
23+
createdAt: new Date(2023, 4, 21, 15, 23).toISOString()
24+
},
25+
{
26+
conversationId: 'foobar',
27+
id: '2',
28+
content: [
29+
{
30+
text: 'Hello! I am your virtual assistant how may I help you?'
31+
}
32+
],
33+
role: 'assistant' as const,
34+
createdAt: new Date(2023, 4, 21, 15, 24).toISOString()
35+
}
36+
];
37+
38+
export const MESSAGES_RESPONSE_COMPONENTS: ConversationMessage[] = [
39+
{
40+
conversationId: 'foobar',
41+
id: '1',
42+
content: [{ text: 'Whats the weather in San Jose?' }],
43+
role: 'user' as const,
44+
createdAt: new Date(2023, 4, 21, 15, 23).toISOString()
45+
},
46+
{
47+
conversationId: 'foobar',
48+
id: '2',
49+
content: [
50+
{
51+
text: 'Let me get the weather for San Jose for you.'
52+
},
53+
{
54+
toolUse: {
55+
name: 'AMPLIFY_UI_WeatherCard',
56+
input: { city: 'San Jose' },
57+
toolUseId: '1234'
58+
}
59+
}
60+
],
61+
role: 'assistant' as const,
62+
createdAt: new Date(2023, 4, 21, 15, 24).toISOString()
63+
}
64+
];

src/components/UIWrapper/UWrapper.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
createTheme,
3+
defaultDarkModeOverride,
4+
ThemeProvider,
5+
View
6+
} from '@aws-amplify/ui-react';
7+
import * as React from 'react';
8+
import { LayoutContext } from '../Layout';
9+
10+
const theme = createTheme({
11+
name: 'default-amplify-ui-theme',
12+
overrides: [defaultDarkModeOverride]
13+
});
14+
15+
export const UIWrapper = ({ children }: React.PropsWithChildren) => {
16+
const { colorMode } = React.useContext(LayoutContext);
17+
18+
return (
19+
<ThemeProvider theme={theme} colorMode={colorMode}>
20+
<View
21+
borderRadius="small"
22+
padding="large"
23+
boxShadow={`0 0 0 2px ${theme.tokens.colors.neutral[20]}`}
24+
>
25+
{children}
26+
</View>
27+
</ThemeProvider>
28+
);
29+
};

src/components/UIWrapper/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { UIWrapper } from './UWrapper';

src/directory/directory.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ export const directory = {
753753
{
754754
path: 'src/pages/[platform]/ai/conversation/index.mdx',
755755
children: [
756+
{
757+
path: 'src/pages/[platform]/ai/conversation/ai-conversation/index.mdx'
758+
},
756759
{
757760
path: 'src/pages/[platform]/ai/conversation/history/index.mdx'
758761
},

0 commit comments

Comments
 (0)