widget final

This commit is contained in:
Alex
2023-09-12 17:36:41 +01:00
parent 7f7856f0e4
commit 45f1bf6709
6 changed files with 13 additions and 12 deletions

View File

@@ -109,9 +109,13 @@ function fetchAnswerStreaming({
export const DocsGPTWidget = ({ apiHost = 'https://gptcloud.arc53.com', selectDocs = 'default', apiKey = 'docsgpt-public'}) => {
// processing states
const [chatState, setChatState] = useState<ChatStates>(
() => localStorage.getItem('docsGPTChatState') as ChatStates || ChatStates.Init
);
const [chatState, setChatState] = useState<ChatStates>(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('docsGPTChatState') as ChatStates || ChatStates.Init;
}
return ChatStates.Init;
});
const [answer, setAnswer] = useState<string>('');
//const selectDocs = 'local/1706.03762.pdf/'
@@ -126,7 +130,7 @@ export const DocsGPTWidget = ({ apiHost = 'https://gptcloud.arc53.com', selectDo
useEffect(() => {
if (chatState === ChatStates.Init || chatState === ChatStates.Minimized) {
localStorage.setItem('docsGPTChatState', chatState);
localStorage.setItem('docsGPTChatState', chatState);
}
}, [chatState]);