Skip to content

Commit

Permalink
feat: send message support ChatMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jun 11, 2024
1 parent 66b0a04 commit 5096c75
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/hooks/useChatList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,19 @@ export const useChatList = (props: ProChatUIUseListChatProps) => {
* @param {string} message - The message to send.
* @returns {Promise<void>} - A promise that resolves when the message is sent.
*/
const sendMessage = useRefFunction(async (message: string) => {
const sendMessage = useRefFunction(async (message: string | Partial<ChatMessage>) => {
controller.current = new AbortController();
chatList.push(genMessageRecord({ content: message }, 'user'));
chatList.push(
genMessageRecord(
typeof message === 'string'
? { content: message }
: {
...message,
content: message.content,
},
'user',
),
);
setChatList([...chatList]);
if (!props?.sendMessageRequest) return;
setLoadingMessage(
Expand Down

0 comments on commit 5096c75

Please sign in to comment.