Skip to content

Commit 9b3467b

Browse files
committed
Merge remote-tracking branch 'origin/main' into schema-validation
2 parents 5d89b56 + 9ab56f4 commit 9b3467b

File tree

136 files changed

+2666
-2565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2666
-2565
lines changed

.changeset/honest-beans-suffer.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@aws-amplify/ui-react-ai": minor
3+
"@aws-amplify/ui": patch
4+
---
5+
6+
feat(ai) add attachment validations
7+
8+
The current limitations on the Amplify AI kit for attachments is 400kb (of base64'd size) per image, and 20 images per message are now being enforced before the message is sent.
9+
These limits can be adjusted via props as well.
10+
11+
```tsx
12+
<AIConversation
13+
maxAttachments={2}
14+
maxAttachmentSize={100_000} // 100,000 bytes or 100kb
15+
/>
16+
```

docs/src/components/ComponentsMetadata.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ export const ComponentsMetadata: ComponentClassNameItems = {
135135
components: ['AIConversation'],
136136
description: 'Class applied to the form element',
137137
},
138+
AIConversationFormError: {
139+
className: ComponentClassName.AIConversationFormError,
140+
components: ['AIConversation'],
141+
description: 'Class applied to the error message of the form',
142+
},
138143
AIConversationFormAttach: {
139144
className: ComponentClassName.AIConversationFormAttach,
140145
components: ['AIConversation'],
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import * as React from 'react';
2+
import { Amplify } from 'aws-amplify';
3+
import { signOut } from 'aws-amplify/auth';
4+
import { createAIHooks, AIConversation } from '@aws-amplify/ui-react-ai';
5+
import { generateClient } from 'aws-amplify/api';
6+
import '@aws-amplify/ui-react/styles.css';
7+
8+
import outputs from './amplify_outputs';
9+
import type { Schema } from '@environments/ai/gen2/amplify/data/resource';
10+
import { Authenticator, Button, Card, Flex } from '@aws-amplify/ui-react';
11+
12+
const client = generateClient<Schema>({ authMode: 'userPool' });
13+
const { useAIConversation } = createAIHooks(client);
14+
15+
Amplify.configure(outputs);
16+
17+
function Chat() {
18+
const [
19+
{
20+
data: { messages },
21+
isLoading,
22+
},
23+
sendMessage,
24+
] = useAIConversation('pirateChat');
25+
26+
return (
27+
<AIConversation
28+
messages={messages}
29+
isLoading={isLoading}
30+
handleSendMessage={sendMessage}
31+
allowAttachments
32+
maxAttachmentSize={100_000}
33+
maxAttachments={2}
34+
/>
35+
);
36+
}
37+
38+
export default function Example() {
39+
return (
40+
<Authenticator>
41+
<Flex direction="column">
42+
<Button
43+
onClick={() => {
44+
signOut();
45+
}}
46+
>
47+
Sign out
48+
</Button>
49+
<Card flex="1" variation="outlined" height="400px" margin="large">
50+
<Chat />
51+
</Card>
52+
</Flex>
53+
</Authenticator>
54+
);
55+
}

examples/next/pages/ui/components/storage/storage-browser/composable-playground/index.page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Auth } from '../managedAuthAdapter';
1111
import { Button, Flex, Breadcrumbs } from '@aws-amplify/ui-react';
1212

1313
import '@aws-amplify/ui-react-storage/styles.css';
14-
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
1514

1615
const components: CreateStorageBrowserInput['components'] = {
1716
Navigation: ({ items }) => (
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import React from 'react';
2+
3+
import { createStorageBrowser } from '@aws-amplify/ui-react-storage/browser';
4+
5+
import { Flex } from '@aws-amplify/ui-react';
6+
7+
import '@aws-amplify/ui-react-storage/styles.css';
8+
9+
const { StorageBrowser } = createStorageBrowser({
10+
actions: {
11+
default: {
12+
copy: {
13+
actionListItem: {
14+
icon: 'copy-file',
15+
label: 'Override Copy',
16+
},
17+
handler: ({ data }) => {
18+
const { key } = data;
19+
return {
20+
result: Promise.resolve({ status: 'COMPLETE', value: { key } }),
21+
};
22+
},
23+
viewName: 'CopyView',
24+
},
25+
createFolder: {
26+
actionListItem: {
27+
icon: 'create-folder',
28+
label: 'Override Create Folder',
29+
},
30+
handler: ({ data }) => {
31+
const { key } = data;
32+
return {
33+
result: Promise.resolve({ status: 'COMPLETE', value: { key } }),
34+
};
35+
},
36+
viewName: 'CreateFolderView',
37+
},
38+
delete: {
39+
actionListItem: {
40+
icon: 'delete-file',
41+
label: 'Override Delete',
42+
},
43+
handler: ({ data }) => {
44+
const { key } = data;
45+
return {
46+
result: Promise.resolve({ status: 'COMPLETE', value: { key } }),
47+
};
48+
},
49+
viewName: 'DeleteView',
50+
},
51+
download: () => {
52+
return {
53+
result: Promise.resolve({
54+
status: 'COMPLETE',
55+
value: { url: new URL('') },
56+
}),
57+
};
58+
},
59+
upload: {
60+
actionListItem: {
61+
icon: 'upload-file',
62+
label: 'Override Upload',
63+
},
64+
handler: ({ data }) => {
65+
const { key } = data;
66+
return {
67+
result: Promise.resolve({ status: 'COMPLETE', value: { key } }),
68+
};
69+
},
70+
viewName: 'UploadView',
71+
},
72+
listLocationItems: () =>
73+
Promise.resolve({
74+
items: [
75+
{
76+
id: 'jaskjkaska',
77+
key: 'item-key',
78+
lastModified: new Date(),
79+
size: 1008,
80+
type: 'FILE' as const,
81+
},
82+
],
83+
nextToken: undefined,
84+
}),
85+
},
86+
},
87+
config: {
88+
getLocationCredentials: () =>
89+
Promise.resolve({
90+
credentials: {
91+
accessKeyId: '',
92+
expiration: new Date(),
93+
secretAccessKey: '',
94+
sessionToken: '',
95+
},
96+
}),
97+
region: '',
98+
registerAuthListener: () => null,
99+
listLocations: () =>
100+
Promise.resolve({
101+
items: [
102+
{
103+
bucket: 'my-bucket',
104+
id: crypto.randomUUID(),
105+
permissions: ['delete', 'get', 'list', 'write'],
106+
prefix: 'my-prefix',
107+
type: 'PREFIX',
108+
},
109+
],
110+
nextToken: undefined,
111+
}),
112+
},
113+
});
114+
115+
function Example() {
116+
return (
117+
<Flex
118+
direction="column"
119+
width="100vw"
120+
height="100vh"
121+
overflow="hidden"
122+
padding="xl"
123+
>
124+
<StorageBrowser />
125+
</Flex>
126+
);
127+
}
128+
129+
export default Example;

examples/next/pages/ui/components/storage/storage-browser/default-auth/index.page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import { StorageBrowser } from '@aws-amplify/ui-react-storage';
1313

1414
import '@aws-amplify/ui-react-storage/styles.css';
15-
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
1615

1716
import config from './aws-exports';
1817

examples/next/pages/ui/components/storage/storage-browser/default-auth/routed/StorageBrowser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
44
createAmplifyAuthAdapter,
55
createStorageBrowser,
66
} from '@aws-amplify/ui-react-storage/browser';
7-
import '@aws-amplify/ui-react-storage/styles.css';
8-
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
97

108
import config from './aws-exports';
119

examples/next/pages/ui/components/storage/storage-browser/default-auth/routed/[locations]/[location-detail]/index.page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Button, Flex } from '@aws-amplify/ui-react';
66

77
import { StorageBrowser } from '../../StorageBrowser';
88

9-
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
109
import '@aws-amplify/ui-react-storage/styles.css';
1110

1211
export default function Page() {

examples/next/pages/ui/components/storage/storage-browser/default-auth/routed/[locations]/index.page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Button, Flex } from '@aws-amplify/ui-react';
66

77
import { StorageBrowser } from '../StorageBrowser';
88

9-
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
109
import '@aws-amplify/ui-react-storage/styles.css';
1110

1211
function Locations() {

examples/next/pages/ui/components/storage/storage-browser/default-auth/routed/index.page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import useIsSignedIn from './useIsSignedIn';
66
import { Authenticator } from '@aws-amplify/ui-react';
77

88
import '@aws-amplify/ui-react-storage/styles.css';
9-
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
109

1110
function Example() {
1211
const router = useRouter();

0 commit comments

Comments
 (0)