react-native-ajora
Version:
The most complete AI agent UI for React Native
55 lines (51 loc) • 1.42 kB
text/typescript
import { createContext, useContext } from "react";
import { ActionSheetOptions } from "@expo/react-native-action-sheet";
import { Ajora } from "./hooks/useAjora";
export interface IAjoraContext {
actionSheet(): {
showActionSheetWithOptions: (
options: ActionSheetOptions,
callback: (buttonIndex?: number) => void | Promise<void>
) => void;
};
getLocale(): string;
ajora: Ajora;
}
export const AjoraContext = createContext<IAjoraContext>({
getLocale: () => "en",
actionSheet: () => ({
showActionSheetWithOptions: () => {},
}),
ajora: {
stream: [],
messages: {},
messagesByThread: [],
threads: [],
activeThreadId: null,
isThinking: false,
loadEarlier: false,
isLoadingMessages: false,
mode: "auto",
baseUrl: "",
apiService: null,
submitQuery: () => Promise.resolve(),
addNewThread: () => {},
switchThread: () => {},
getThreads: () => {},
getMessages: () => {},
setIsThinking: () => {},
setIsLoadingEarlier: () => {},
setMode: () => {},
regenerateMessage: () => {},
setIsComplete: () => {},
setAttachement: () => {},
updateAttachement: () => {},
clearAttachement: () => {},
setIsRecording: () => {},
isComplete: false,
attachement: undefined,
isRecording: false,
stopStreaming: () => {},
},
});
export const useChatContext = () => useContext(AjoraContext);