Skip to content

Commit

Permalink
fix (docs): update save state example (#2276)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalbanese authored Jul 15, 2024
1 parent 9d4ed83 commit 92217a8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Learn to save and restore AI and UI states with onGetUIState and on

Sometimes conversations with language models can get interesting and you might want to save the state of so you can revisit it or continue the conversation later.

`createAI` has an experimental callback function called `unstable_onSetAI` that gets called whenever the AI state changes. You can use this to save the AI state to a filename or a database.
`createAI` has an experimental callback function called `onSetAIState` that gets called whenever the AI state changes. You can use this to save the AI state to a filename or a database.

## Client

Expand Down Expand Up @@ -177,14 +177,14 @@ export const AI = createAI<ServerMessage[], ClientMessage[]>({
actions: {
continueConversation,
},
unstable_onSetAIState: async ({ state, done }) => {
onSetAIState: async ({ state, done }) => {
'use server';

if (done) {
saveChat(state);
}
},
unstable_onGetUIState: async () => {
onGetUIState: async () => {
'use server';

const history: ServerMessage[] = getAIState();
Expand Down

0 comments on commit 92217a8

Please sign in to comment.