Skip to content

Commit

Permalink
core/types: fix types to support async onResponse callback (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLeiter committed Jun 21, 2023
1 parent 7815b11 commit bde3898
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-kangaroos-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'ai': patch
---

Allow an async onResponse callback in useChat/useCompletion
5 changes: 3 additions & 2 deletions packages/core/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type UseChatOptions = {
/**
* Callback function to be called when the API response is received.
*/
onResponse?: (response: Response) => void
onResponse?: (response: Response) => void | Promise<void>

/**
* Callback function to be called when the chat is finished streaming.
Expand Down Expand Up @@ -107,7 +107,8 @@ export type UseCompletionOptions = {
/**
* Callback function to be called when the API response is received.
*/
onResponse?: (response: Response) => void
onResponse?: (response: Response) => void | Promise<void>

/**
* Callback function to be called when the completion is finished streaming.
*/
Expand Down

0 comments on commit bde3898

Please sign in to comment.