-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow custom submit and adding event handlers (#23)
- Loading branch information
1 parent
f66a1f7
commit 68555c3
Showing
9 changed files
with
1,284 additions
and
509 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.github | ||
.eslintrc | ||
.eslintignore | ||
.eslintignore.json | ||
.prettierignore | ||
.prettierrc | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import useChatStream from './hooks/useChatStream'; | ||
|
||
export * from './types'; | ||
export default useChatStream; |
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,36 @@ | ||
import useChatStream from './hooks/useChatStream'; | ||
|
||
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; | ||
|
||
export type UseChatStreamRole = 'bot' | 'user'; | ||
|
||
export type UseChatStreamChatMessage = { | ||
role: UseChatStreamRole; | ||
content: string; | ||
id: string, | ||
} | ||
|
||
export type UseChatStreamHttpOptions = { | ||
url: string; | ||
method: HttpMethod; | ||
query?: Record<string, string>; | ||
headers?: HeadersInit; | ||
body?: Record<string, string>; | ||
} | ||
|
||
export type UseChatStreamEventHandlers = { | ||
onMessageAdded: (message: UseChatStreamChatMessage) => unknown | Promise<unknown>; | ||
} | ||
|
||
export type UseChatStreamInputMethod = { | ||
type: 'body' | 'query', | ||
key: string; | ||
} | ||
|
||
export type UseChatStreamInput = { | ||
options: UseChatStreamHttpOptions, | ||
method: UseChatStreamInputMethod, | ||
handlers: UseChatStreamEventHandlers | ||
}; | ||
|
||
export type UseChatStreamResult = ReturnType<typeof useChatStream>; |
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.