UNPKG

@scoopika/react

Version:

Build interactive AI-powered React applications around AI agents

76 lines (72 loc) 3.24 kB
import * as _scoopika_types from '@scoopika/types'; import { RunHistory, ModelRunHistory, RunInputs, RunOptions, Hooks } from '@scoopika/types'; import * as react from 'react'; import { AgentClient, VoiceRecorder, RunVoicePlayer, VoiceVisualizer } from '@scoopika/client'; interface UseChatStateOptions { session_id?: string; scroll?: () => any; messages?: RunHistory[]; } declare function useChatState(agent: string | AgentClient, state_options?: UseChatStateOptions): { generating: boolean; loading: boolean; status: string | undefined; streamPlaceholder: ModelRunHistory | undefined; messages: RunHistory[]; setMessages: react.Dispatch<react.SetStateAction<RunHistory[]>>; newRequest: ({ inputs, options, hooks, }?: { inputs?: RunInputs; options?: RunOptions; hooks?: Hooks; }) => Promise<_scoopika_types.ModelTextResponse>; agent: AgentClient; session: string; setSession: react.Dispatch<react.SetStateAction<string>>; }; interface UseVoiceChatStateOptions extends UseChatStateOptions { auto_play_audio?: boolean; allowInBrowserSpeechRecognition?: boolean; agent_voice?: { audio: HTMLAudioElement | string; canvas?: HTMLCanvasElement | string; wave_color?: string; }; } declare function useVoiceChatState(agent: string | AgentClient, state_options?: UseVoiceChatStateOptions): { voiceRecorder: VoiceRecorder | null; setVoiceRecorder: react.Dispatch<react.SetStateAction<VoiceRecorder | null>>; voicePlaying: boolean; setVoicePlaying: react.Dispatch<react.SetStateAction<boolean>>; agentVoicePlayer: RunVoicePlayer | null; setAgentVoicePlayer: react.Dispatch<react.SetStateAction<RunVoicePlayer | null>>; newRequest: ({ inputs, options, hooks, }?: { inputs?: RunInputs; options?: RunOptions; hooks?: Hooks; }) => Promise<_scoopika_types.ModelTextResponse>; visualizer: VoiceVisualizer | null; setVisualizer: react.Dispatch<react.SetStateAction<VoiceVisualizer | null>>; recorderState: "recording" | "paused" | "stopped"; setRecorderState: react.Dispatch<react.SetStateAction<"recording" | "paused" | "stopped">>; recognizedText: string | undefined; setRecognizedText: react.Dispatch<react.SetStateAction<string | undefined>>; supportRecognition: boolean | null; setSupportRecognition: react.Dispatch<react.SetStateAction<boolean | null>>; updateRecognizedText: (text: string) => void; working: boolean; setWorking: react.Dispatch<react.SetStateAction<boolean>>; pauseAgentVoice: () => void; resumeAgentVoice: () => void; agentVoicePaused: boolean; setPlayerPaused: react.Dispatch<react.SetStateAction<boolean>>; generating: boolean; loading: boolean; status: string | undefined; streamPlaceholder: _scoopika_types.ModelRunHistory | undefined; messages: _scoopika_types.RunHistory[]; setMessages: react.Dispatch<react.SetStateAction<_scoopika_types.RunHistory[]>>; agent: AgentClient; session: string; setSession: react.Dispatch<react.SetStateAction<string>>; }; export { type UseChatStateOptions, type UseVoiceChatStateOptions, useChatState, useVoiceChatState };