From bd68615b7d2520d5fdd1d7e4d33514ddb322ac6e Mon Sep 17 00:00:00 2001 From: Niels Bosman Date: Tue, 17 Oct 2023 20:24:04 +0200 Subject: [PATCH] feat: call fetch ai response with direct value --- package.json | 2 +- src/hooks/useChatStream.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7002f6e..b908301 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@magicul/react-chat-stream", "description": "A React hook that lets you easily integrate your custom ChatGPT-like chat in React.", - "version": "0.1.7", + "version": "0.2.0", "main": "dist/index.js", "types": "dist/index.d.ts", "homepage": "https://github.com/XD2Sketch/react-chat-stream#readme", diff --git a/src/hooks/useChatStream.ts b/src/hooks/useChatStream.ts index 9bee435..3dbceeb 100644 --- a/src/hooks/useChatStream.ts +++ b/src/hooks/useChatStream.ts @@ -64,7 +64,7 @@ const useChatStream = (input: UseChatStreamInput): UseChatStreamResult => { }); }; - const fetchAndUpdateAIResponse = async () => { + const fetchAndUpdateAIResponse = async (message: string) => { const stream = await getStream(message, input.options, input.method); if (!stream) throw new Error(); @@ -82,7 +82,7 @@ const useChatStream = (input: UseChatStreamInput): UseChatStreamResult => { setMessage(''); try { - await fetchAndUpdateAIResponse(); + await fetchAndUpdateAIResponse(newMessage ?? message); } catch { addMessageToChat(BOT_ERROR_MESSAGE, 'bot'); }