-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sto-bro-docs
- Loading branch information
Showing
153 changed files
with
3,378 additions
and
2,911 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
"@aws-amplify/ui-react-ai": minor | ||
"@aws-amplify/ui": patch | ||
--- | ||
|
||
feat(ai) add attachment validations | ||
|
||
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. | ||
These limits can be adjusted via props as well. | ||
|
||
```tsx | ||
<AIConversation | ||
maxAttachments={2} | ||
maxAttachmentSize={100_000} // 100,000 bytes or 100kb | ||
/> | ||
``` |
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
55 changes: 55 additions & 0 deletions
55
examples/next/pages/ui/components/ai/ai-conversation/attachments.page.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,55 @@ | ||
import * as React from 'react'; | ||
import { Amplify } from 'aws-amplify'; | ||
import { signOut } from 'aws-amplify/auth'; | ||
import { createAIHooks, AIConversation } from '@aws-amplify/ui-react-ai'; | ||
import { generateClient } from 'aws-amplify/api'; | ||
import '@aws-amplify/ui-react/styles.css'; | ||
|
||
import outputs from './amplify_outputs'; | ||
import type { Schema } from '@environments/ai/gen2/amplify/data/resource'; | ||
import { Authenticator, Button, Card, Flex } from '@aws-amplify/ui-react'; | ||
|
||
const client = generateClient<Schema>({ authMode: 'userPool' }); | ||
const { useAIConversation } = createAIHooks(client); | ||
|
||
Amplify.configure(outputs); | ||
|
||
function Chat() { | ||
const [ | ||
{ | ||
data: { messages }, | ||
isLoading, | ||
}, | ||
sendMessage, | ||
] = useAIConversation('pirateChat'); | ||
|
||
return ( | ||
<AIConversation | ||
messages={messages} | ||
isLoading={isLoading} | ||
handleSendMessage={sendMessage} | ||
allowAttachments | ||
maxAttachmentSize={100_000} | ||
maxAttachments={2} | ||
/> | ||
); | ||
} | ||
|
||
export default function Example() { | ||
return ( | ||
<Authenticator> | ||
<Flex direction="column"> | ||
<Button | ||
onClick={() => { | ||
signOut(); | ||
}} | ||
> | ||
Sign out | ||
</Button> | ||
<Card flex="1" variation="outlined" height="400px" margin="large"> | ||
<Chat /> | ||
</Card> | ||
</Flex> | ||
</Authenticator> | ||
); | ||
} |
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
129 changes: 129 additions & 0 deletions
129
examples/next/pages/ui/components/storage/storage-browser/custom-actions/index.page.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,129 @@ | ||
import React from 'react'; | ||
|
||
import { createStorageBrowser } from '@aws-amplify/ui-react-storage/browser'; | ||
|
||
import { Flex } from '@aws-amplify/ui-react'; | ||
|
||
import '@aws-amplify/ui-react-storage/styles.css'; | ||
|
||
const { StorageBrowser } = createStorageBrowser({ | ||
actions: { | ||
default: { | ||
copy: { | ||
actionListItem: { | ||
icon: 'copy-file', | ||
label: 'Override Copy', | ||
}, | ||
handler: ({ data }) => { | ||
const { key } = data; | ||
return { | ||
result: Promise.resolve({ status: 'COMPLETE', value: { key } }), | ||
}; | ||
}, | ||
viewName: 'CopyView', | ||
}, | ||
createFolder: { | ||
actionListItem: { | ||
icon: 'create-folder', | ||
label: 'Override Create Folder', | ||
}, | ||
handler: ({ data }) => { | ||
const { key } = data; | ||
return { | ||
result: Promise.resolve({ status: 'COMPLETE', value: { key } }), | ||
}; | ||
}, | ||
viewName: 'CreateFolderView', | ||
}, | ||
delete: { | ||
actionListItem: { | ||
icon: 'delete-file', | ||
label: 'Override Delete', | ||
}, | ||
handler: ({ data }) => { | ||
const { key } = data; | ||
return { | ||
result: Promise.resolve({ status: 'COMPLETE', value: { key } }), | ||
}; | ||
}, | ||
viewName: 'DeleteView', | ||
}, | ||
download: () => { | ||
return { | ||
result: Promise.resolve({ | ||
status: 'COMPLETE', | ||
value: { url: new URL('') }, | ||
}), | ||
}; | ||
}, | ||
upload: { | ||
actionListItem: { | ||
icon: 'upload-file', | ||
label: 'Override Upload', | ||
}, | ||
handler: ({ data }) => { | ||
const { key } = data; | ||
return { | ||
result: Promise.resolve({ status: 'COMPLETE', value: { key } }), | ||
}; | ||
}, | ||
viewName: 'UploadView', | ||
}, | ||
listLocationItems: () => | ||
Promise.resolve({ | ||
items: [ | ||
{ | ||
id: 'jaskjkaska', | ||
key: 'item-key', | ||
lastModified: new Date(), | ||
size: 1008, | ||
type: 'FILE' as const, | ||
}, | ||
], | ||
nextToken: undefined, | ||
}), | ||
}, | ||
}, | ||
config: { | ||
getLocationCredentials: () => | ||
Promise.resolve({ | ||
credentials: { | ||
accessKeyId: '', | ||
expiration: new Date(), | ||
secretAccessKey: '', | ||
sessionToken: '', | ||
}, | ||
}), | ||
region: '', | ||
registerAuthListener: () => null, | ||
listLocations: () => | ||
Promise.resolve({ | ||
items: [ | ||
{ | ||
bucket: 'my-bucket', | ||
id: crypto.randomUUID(), | ||
permissions: ['delete', 'get', 'list', 'write'], | ||
prefix: 'my-prefix', | ||
type: 'PREFIX', | ||
}, | ||
], | ||
nextToken: undefined, | ||
}), | ||
}, | ||
}); | ||
|
||
function Example() { | ||
return ( | ||
<Flex | ||
direction="column" | ||
width="100vw" | ||
height="100vh" | ||
overflow="hidden" | ||
padding="xl" | ||
> | ||
<StorageBrowser /> | ||
</Flex> | ||
); | ||
} | ||
|
||
export default Example; |
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
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
Oops, something went wrong.