-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat-storage-browser/main' into feat-storage-browser/ta…
…ble-load-state
- Loading branch information
Showing
117 changed files
with
1,820 additions
and
722 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,21 @@ | ||
--- | ||
"@aws-amplify/ui-react-ai": minor | ||
--- | ||
|
||
feat(ai): add aiContext prop to AIConversation | ||
|
||
```tsx | ||
<AIConversation | ||
messages={messages} | ||
isLoading={isLoading} | ||
handleSendMessage={sendMessage} | ||
// This will let the LLM know about the current state of this application | ||
// so it can better respond to questions, you can put any information | ||
// in this object that might be helpful | ||
aiContext={() => { | ||
return { | ||
currentTime: new Date().toLocaleTimeString(), | ||
}; | ||
}} | ||
/> | ||
``` |
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,5 @@ | ||
--- | ||
"@aws-amplify/ui-react-core": patch | ||
--- | ||
|
||
chore: fix issue where drag and drop throws illegal invocation |
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,7 @@ | ||
--- | ||
"@aws-amplify/ui-react-ai": major | ||
"@aws-amplify/ui-react": patch | ||
"@aws-amplify/ui": patch | ||
--- | ||
|
||
chore: get ai package ready for release |
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
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 |
---|---|---|
|
@@ -100,8 +100,13 @@ if [[ "$FRAMEWORK" == 'react-native' ]]; then | |
echo "rm -rf $MEGA_APP_NAME" # Remove $MEGA_APP_NAME if it exists | ||
rm -rf $MEGA_APP_NAME | ||
if [[ "$BUILD_TOOL" == 'cli' ]]; then | ||
echo "npx react-native@${BUILD_TOOL_VERSION} init $MEGA_APP_NAME --version $FRAMEWORK_VERSION" | ||
npx react-native@${BUILD_TOOL_VERSION} init $MEGA_APP_NAME --version $FRAMEWORK_VERSION | ||
if [[ $BUILD_TOOL_VERSION == 9 ]]; then # RN CLI v9 doesn't recognize --pm flag | ||
echo "npx @react-native-community/cli@$BUILD_TOOL_VERSION init $MEGA_APP_NAME --version $FRAMEWORK_VERSION" | ||
npx @react-native-community/cli@$BUILD_TOOL_VERSION init $MEGA_APP_NAME --version $FRAMEWORK_VERSION | ||
else # --pm flag fixes https://github.com/CocoaPods/CocoaPods/issues/12546 | ||
echo "npx @react-native-community/cli@$BUILD_TOOL_VERSION init $MEGA_APP_NAME --version $FRAMEWORK_VERSION --pm npm" | ||
npx @react-native-community/cli@$BUILD_TOOL_VERSION init $MEGA_APP_NAME --version $FRAMEWORK_VERSION --pm npm | ||
fi | ||
# React-Native, since 0.71.8, | ||
# no longer shows warning "npm WARN exec The following package was not found and will be installed: [email protected]", | ||
# so we log the package.json to check the versions | ||
|
@@ -110,11 +115,11 @@ if [[ "$FRAMEWORK" == 'react-native' ]]; then | |
echo "npm list react-native" | ||
npm list react-native | ||
elif [[ "$BUILD_TOOL" == "expo" ]]; then | ||
echo "npx create-expo-app $MEGA_APP_NAME --template expo-template-blank-typescript@sdk-51" | ||
npx create-expo-app $MEGA_APP_NAME --template expo-template-blank-typescript@sdk-51 # Temporarily pin expo to version 51 | ||
echo "npx create-expo-app $MEGA_APP_NAME --template expo-template-blank-typescript@$BUILD_TOOL_VERSION" | ||
npx create-expo-app $MEGA_APP_NAME --template expo-template-blank-typescript@$BUILD_TOOL_VERSION | ||
echo "cd $MEGA_APP_NAME" | ||
cd $MEGA_APP_NAME | ||
echo "npm list expo" # Log the package.json to check the expo version should be later than 48.0.19 | ||
echo "npm list expo" # Log the package.json to check the expo version | ||
npm list expo | ||
echo "npx expo-env-info" | ||
npx expo-env-info | ||
|
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
98 changes: 98 additions & 0 deletions
98
examples/next/pages/ui/components/ai/ai-conversation/context.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,98 @@ | ||
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 } = React.useContext(AIContext); | ||
const [ | ||
{ | ||
data: { messages }, | ||
isLoading, | ||
}, | ||
sendMessage, | ||
] = useAIConversation('pirateChat'); | ||
|
||
return ( | ||
<AIConversation | ||
messages={messages} | ||
isLoading={isLoading} | ||
handleSendMessage={sendMessage} | ||
// This will let the LLM know about the current state of this application | ||
// so it can better respond to questions | ||
aiContext={() => { | ||
return { | ||
...data, | ||
currentTime: new Date().toLocaleTimeString(), | ||
}; | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
function Counter() { | ||
const { data, setData } = React.useContext(AIContext); | ||
const count = data.count ?? 0; | ||
return ( | ||
<Button onClick={() => setData({ ...data, count: count + 1 })}> | ||
{count} | ||
</Button> | ||
); | ||
} | ||
|
||
const AIContext = React.createContext<{ | ||
data: any; | ||
setData: (value: React.SetStateAction<any>) => void; | ||
}>({ data: {}, setData: () => {} }); | ||
|
||
const AIContextProvider = ({ | ||
children, | ||
}: { | ||
children?: React.ReactNode; | ||
}): JSX.Element => { | ||
const [data, setData] = React.useState({}); | ||
return ( | ||
<AIContext.Provider value={{ data, setData }}> | ||
{children} | ||
</AIContext.Provider> | ||
); | ||
}; | ||
|
||
export default function Example() { | ||
return ( | ||
<Authenticator> | ||
<AIContextProvider> | ||
<Flex direction="column" alignItems="flex-start"> | ||
<Button | ||
onClick={() => { | ||
signOut(); | ||
}} | ||
> | ||
Sign out | ||
</Button> | ||
<Card | ||
flex="1" | ||
variation="outlined" | ||
// height="400px" | ||
width="100%" | ||
margin="large" | ||
> | ||
<Chat /> | ||
</Card> | ||
<Counter /> | ||
</Flex> | ||
</AIContextProvider> | ||
</Authenticator> | ||
); | ||
} |
Oops, something went wrong.