11import { useEffect , useState } from 'react' ;
22
3- import { Channel , Event } from 'stream-chat' ;
3+ import { AIState , Channel , Event } from 'stream-chat' ;
44
55import { useChatContext } from '../../../contexts' ;
66import type { DefaultStreamChatGenerics } from '../../../types/types' ;
77import { useIsOnline } from '../../Chat/hooks/useIsOnline' ;
88
9- export type AIStateType =
10- | 'AI_STATE_ERROR'
11- | 'AI_STATE_EXTERNAL_SOURCES'
12- | 'AI_STATE_GENERATING'
13- | 'AI_STATE_IDLE'
14- | 'AI_STATE_THINKING'
15- | string ;
16-
179export const AIStates = {
1810 Error : 'AI_STATE_ERROR' ,
1911 ExternalSources : 'AI_STATE_EXTERNAL_SOURCES' ,
@@ -28,7 +20,7 @@ export const useAIState = <
2820 channel ?: Channel < StreamChatGenerics > ,
2921) => {
3022 const { client } = useChatContext ( ) ;
31- const [ aiState , setAiState ] = useState < AIStateType > ( AIStates . Idle ) ;
23+ const [ aiState , setAiState ] = useState < AIState > ( AIStates . Idle ) ;
3224 const { isOnline } = useIsOnline ( client ) ;
3325
3426 useEffect ( ( ) => {
@@ -46,7 +38,7 @@ export const useAIState = <
4638 'ai_indicator.update' ,
4739 ( event : Event < StreamChatGenerics > ) => {
4840 const { cid } = event ;
49- const state = event . ai_state as AIStateType ;
41+ const state = event . ai_state as AIState ;
5042 if ( channel . cid === cid ) {
5143 setAiState ( state ) ;
5244 }
0 commit comments