diff --git a/src/components/Chat/Chat.tsx b/src/components/Chat/Chat.tsx
index f239a31..fde63af 100644
--- a/src/components/Chat/Chat.tsx
+++ b/src/components/Chat/Chat.tsx
@@ -1,8 +1,8 @@
import React from 'react';
import ChatContent from './ChatContent';
-import ChatInput from './ChatInput';
import MobileBar from '../MobileBar';
+import StopGeneratingButton from '@components/StopGeneratingButton/StopGeneratingButton';
const Chat = () => {
return (
@@ -10,7 +10,7 @@ const Chat = () => {
- {/* */}
+
);
diff --git a/src/components/StopGeneratingButton/StopGeneratingButton.tsx b/src/components/StopGeneratingButton/StopGeneratingButton.tsx
new file mode 100644
index 0000000..e3c7fba
--- /dev/null
+++ b/src/components/StopGeneratingButton/StopGeneratingButton.tsx
@@ -0,0 +1,38 @@
+import React from 'react';
+import useStore from '@store/store';
+
+const StopGeneratingButton = () => {
+ const setGenerating = useStore((state) => state.setGenerating);
+ const generating = useStore((state) => state.generating);
+
+ return generating ? (
+
setGenerating(false)}
+ >
+
+
+ ) : (
+ <>>
+ );
+};
+
+export default StopGeneratingButton;
diff --git a/src/hooks/useSubmit.ts b/src/hooks/useSubmit.ts
index 29703c9..e776748 100644
--- a/src/hooks/useSubmit.ts
+++ b/src/hooks/useSubmit.ts
@@ -45,7 +45,7 @@ const useSubmit = () => {
if (stream) {
const reader = stream.getReader();
let reading = true;
- while (reading) {
+ while (reading && useStore.getState().generating) {
const { done, value } = await reader.read();
const result = parseEventSource(new TextDecoder().decode(value));