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

Adding AIConversation docs #8116

Merged
merged 11 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,8 @@
"ampx",
"autodetection",
"jamba",
"knowledgebases"
"knowledgebases",
"rehype"
],
"flagWords": ["hte", "full-stack", "Full-stack", "Full-Stack", "sudo"],
"patterns": [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@aws-amplify/amplify-cli-core": "^4.3.9",
"@aws-amplify/ui-react": "^6.3.1",
"@aws-amplify/ui-react-ai": "^1.0.0",
"@docsearch/react": "3",
"ajv": "^8.16.0",
"aws-amplify": "^6.0.9",
Expand Down
Binary file added public/images/user.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions src/components/AI/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Avatar } from '@aws-amplify/ui-react';
import { ConversationMessage } from '@aws-amplify/ui-react-ai';
import { AmplifyLogo } from '@/components/GlobalNav/components/icons';

export const UserAvatar = () => {
return <Avatar src="/images/user.jpg" />;
};

export const AssistantAvatar = () => {
return (
<Avatar backgroundColor={'primary.20'}>
<AmplifyLogo />
</Avatar>
);
};

export const MESSAGES: ConversationMessage[] = [
{
conversationId: 'foobar',
id: '1',
content: [{ text: 'Hello' }],
role: 'user' as const,
createdAt: new Date(2023, 4, 21, 15, 23).toISOString()
},
{
conversationId: 'foobar',
id: '2',
content: [
{
text: 'Hello! I am your virtual assistant how may I help you?'
}
],
role: 'assistant' as const,
createdAt: new Date(2023, 4, 21, 15, 24).toISOString()
}
];

export const MESSAGES_RESPONSE_COMPONENTS: ConversationMessage[] = [
{
conversationId: 'foobar',
id: '1',
content: [{ text: 'Whats the weather in San Jose?' }],
role: 'user' as const,
createdAt: new Date(2023, 4, 21, 15, 23).toISOString()
},
{
conversationId: 'foobar',
id: '2',
content: [
{
text: 'Let me get the weather for San Jose for you.'
},
{
toolUse: {
name: 'AMPLIFY_UI_WeatherCard',
input: { city: 'San Jose' },
toolUseId: '1234'
}
}
],
role: 'assistant' as const,
createdAt: new Date(2023, 4, 21, 15, 24).toISOString()
}
];
29 changes: 29 additions & 0 deletions src/components/UIWrapper/UWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
createTheme,
defaultDarkModeOverride,
ThemeProvider,
View
} from '@aws-amplify/ui-react';
import * as React from 'react';
import { LayoutContext } from '../Layout';

const theme = createTheme({
name: 'default-amplify-ui-theme',
overrides: [defaultDarkModeOverride]
});

export const UIWrapper = ({ children }: React.PropsWithChildren) => {
const { colorMode } = React.useContext(LayoutContext);

return (
<ThemeProvider theme={theme} colorMode={colorMode}>
<View
borderRadius="small"
padding="large"
boxShadow={`0 0 0 2px ${theme.tokens.colors.neutral[20]}`}
>
{children}
</View>
</ThemeProvider>
);
};
1 change: 1 addition & 0 deletions src/components/UIWrapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { UIWrapper } from './UWrapper';
3 changes: 3 additions & 0 deletions src/directory/directory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,9 @@ export const directory = {
{
path: 'src/pages/[platform]/ai/conversation/index.mdx',
children: [
{
path: 'src/pages/[platform]/ai/conversation/ai-conversation/index.mdx'
},
{
path: 'src/pages/[platform]/ai/conversation/history/index.mdx'
},
Expand Down
Loading
Loading