Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Choose your framework/language

Page updated Nov 18, 2024

Context

For LLMs to provide high-quality answers to users' questions, they need to have the right information. Sometimes this information is contextual, based on the user or the state of the application. To allow for this, you can send aiContext with any user message to the LLM, which can be any unstructured or structured data that might be useful.

export default function Chat() {
const [
{
data: { messages },
isLoading,
},
sendMessage,
] = useAIConversation('chat');
function handleSendMessage(message) {
sendMessage({
...message,
// this can be any object that can be stringified
aiContext: {
currentTime: new Date().toLocaleTimeString()
}
})
}
return (
//...
)
}