Merge branch 'ItzCrazyKns:master' into master

This commit is contained in:
sagit 2024-08-30 12:39:05 +08:00 committed by GitHub
commit f51541195e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 129 additions and 2421 deletions

View file

@ -59,7 +59,9 @@ const useSocket = (
chatModelProvider = Object.keys(chatModelProviders)[0];
if (chatModelProvider === 'custom_openai') {
toast.error('Seems like you are using the custom OpenAI provider, please open the settings and configure the API key and base URL');
toast.error(
'Seems like you are using the custom OpenAI provider, please open the settings and configure the API key and base URL',
);
setError(true);
return;
} else {
@ -192,20 +194,13 @@ const useSocket = (
if (data.type === 'error') {
toast.error(data.data);
}
})
});
setWs(ws);
};
connectWs();
}
return () => {
if (ws?.readyState === 1) {
ws?.close();
console.log('[DEBUG] closed');
}
};
}, [ws, url, setIsWSReady, setError]);
return ws;
@ -311,6 +306,15 @@ const ChatWindow = ({ id }: { id?: string }) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
return () => {
if (ws?.readyState === 1) {
ws.close();
console.log('[DEBUG] closed');
}
};
}, []);
const messagesRef = useRef<Message[]>([]);
useEffect(() => {