File size: 1,116 Bytes
1c0c94d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import { createContext, useContext, useEffect, useState } from 'react'
import { getRuntime } from '../api/client.js'
const RuntimeContext = createContext({
plate_ocr_enabled: true,
vlm_enabled: true,
auto_confirm_threshold: 0.85,
review_threshold: 0.55,
})
export function RuntimeProvider({ children }) {
const [runtime, setRuntime] = useState(null)
useEffect(() => {
getRuntime().then(setRuntime).catch(() => setRuntime({}))
}, [])
return <RuntimeContext.Provider value={runtime || {}}>{children}</RuntimeContext.Provider>
}
export const useRuntime = () => useContext(RuntimeContext)
export function RuntimeBanner() {
const rt = useRuntime()
const msgs = []
if (rt && rt.plate_ocr_enabled === false)
msgs.push('Plate reading is OFF (set PLATE_PROVIDER=fastalpr in .env to enable).')
if (rt && rt.vlm_enabled === false)
msgs.push('AI verification (VLM) is OFF — ambiguous cases route to human review.')
if (!msgs.length) return null
return (
<div className="banner warnb">
{msgs.map((m, i) => (
<div key={i}>⚠️ {m}</div>
))}
</div>
)
}
|