import { createContext, useContext } from "react"; export type LoadState = { error: string | null; message: string; progress: number; status: "idle" | "loading" | "ready" | "error"; }; export type VLMContextValue = LoadState & { generateCaption: (request: { frame: ImageData; onStream?: (text: string) => void; prompt: string; }) => Promise; loadModel: () => Promise; }; export const VLMContext = createContext(null); export function useVLM() { const context = useContext(VLMContext); if (!context) { throw new Error("useVLM must be used within a VLMProvider."); } return context; }