| 10 | }; |
| 11 | |
| 12 | export const useChatState = () => { |
| 13 | |
| 14 | |
| 15 | const [assistantName, setAssistantName] = useState(''); |
| 16 | const [assistantModel, setAssistantModel] = useState('gpt-3.5-turbo-1106'); |
| 17 | const [assistantDescription, setAssistantDescription] = useState(''); |
| 18 | const [inputmessage, setInputmessage] = useState(''); |
| 19 | const [chatMessages, setChatMessages] = useState<{ role: string; content: any; }[]>([]); |
| 20 | const [chatStarted, setChatStarted] = useState(false); |
| 21 | const [isButtonDisabled, setIsButtonDisabled] = useState(false); |
| 22 | const [files, setFiles] = useState<File[]>([]); |
| 23 | const [threadId, setThreadId] = useState<string | null>(null); |
| 24 | const [isStartLoading, setStartLoading] = useState(false); |
| 25 | const [isSending, setIsSending] = useState(false); |
| 26 | const [initialThreadMessage, setInitialThreadMessage] = useState('You are a Pirate! introduce yourself'); |
| 27 | const [statusMessage, setStatusMessage] = useState(''); |
| 28 | const counter = useRef(0); |
| 29 | const inputRef = useRef(null); |
| 30 | const formRef = useRef(null); |
| 31 | const [chatManager, setChatManager] = useState<ChatManager | null>(null); |
| 32 | const [assistantId, setAssistantId] = useState<string | null>(process.env.REACT_APP_ASSISTANT_ID || ''); |
| 33 | const [isMessageLoading, setIsMessageLoading] = useState(false); |
| 34 | const [progress, setProgress] = useState(0); |
| 35 | const [isLoadingFirstMessage, setIsLoadingFirstMessage] = useState(false); |
| 36 | const [chatUploadedFiles, setChatUploadedFiles] = useState<File[]>([]); |
| 37 | const [chatFileDetails, setChatFileDetails] = useState<FileDetail[]>([]); |
| 38 | const [fileIds, setFileIds] = useState<string[]>([]); |
| 39 | |
| 40 | |
| 41 | return { |
| 42 | assistantName, setAssistantName, |
| 43 | assistantModel, setAssistantModel, |
| 44 | assistantDescription, setAssistantDescription, |
| 45 | inputmessage, setInputmessage, |
| 46 | chatMessages, setChatMessages, |
| 47 | chatStarted, setChatStarted, |
| 48 | isButtonDisabled, setIsButtonDisabled, |
| 49 | files, setFiles, |
| 50 | assistantId, setAssistantId, |
| 51 | threadId, setThreadId, |
| 52 | isStartLoading, setStartLoading, |
| 53 | isSending, setIsSending, |
| 54 | statusMessage, setStatusMessage, |
| 55 | counter, |
| 56 | inputRef, |
| 57 | formRef, |
| 58 | initialThreadMessage, |
| 59 | setInitialThreadMessage, |
| 60 | chatManager, setChatManager, |
| 61 | isMessageLoading, setIsMessageLoading, |
| 62 | progress, setProgress, |
| 63 | isLoadingFirstMessage, setIsLoadingFirstMessage, |
| 64 | chatUploadedFiles, setChatUploadedFiles, |
| 65 | chatFileDetails, setChatFileDetails, |
| 66 | fileIds, setFileIds, |
| 67 | |
| 68 | |
| 69 | }; |