import { ChevronDown } from "lucide-react"; import { MODEL_OPTIONS } from "../constants/models"; import LiquidAILogo from "./icons/LiquidAILogo"; import HfLogo from "./icons/HfLogo"; import { useEffect, useRef } from "react"; export const LoadingScreen = ({ isLoading, progress, error, loadSelectedModel, selectedModelId, isModelDropdownOpen, setIsModelDropdownOpen, handleModelSelect, }: { isLoading: boolean; progress: number; error: string | null; loadSelectedModel: () => void; selectedModelId: string; isModelDropdownOpen: boolean; setIsModelDropdownOpen: (isOpen: boolean) => void; handleModelSelect: (modelId: string) => void; }) => { const model = MODEL_OPTIONS.find((opt) => opt.id === selectedModelId); const canvasRef = useRef(null); // Background Animation Effect useEffect(() => { const canvas = canvasRef.current; if (!canvas) return; const ctx = canvas.getContext("2d"); if (!ctx) return; let animationFrameId: number; let dots: { x: number; y: number; radius: number; speed: number; opacity: number; blur: number; }[] = []; const setup = () => { canvas.width = window.innerWidth; canvas.height = window.innerHeight; dots = []; const numDots = Math.floor((canvas.width * canvas.height) / 15000); for (let i = 0; i < numDots; ++i) { dots.push({ x: Math.random() * canvas.width, y: Math.random() * canvas.height, radius: Math.random() * 1.5 + 0.5, speed: Math.random() * 0.5 + 0.1, opacity: Math.random() * 0.5 + 0.2, blur: Math.random() > 0.7 ? Math.random() * 2 + 1 : 0, }); } }; const draw = () => { if (!ctx) return; ctx.clearRect(0, 0, canvas.width, canvas.height); dots.forEach((dot) => { // Update dot position dot.y += dot.speed; if (dot.y > canvas.height) { dot.y = 0 - dot.radius; dot.x = Math.random() * canvas.width; } // Draw dot ctx.beginPath(); ctx.arc(dot.x, dot.y, dot.radius, 0, Math.PI * 2); ctx.fillStyle = `rgba(255, 255, 255, ${dot.opacity})`; if (dot.blur > 0) { ctx.filter = `blur(${dot.blur}px)`; } ctx.fill(); ctx.filter = "none"; // Reset filter }); animationFrameId = requestAnimationFrame(draw); }; const handleResize = () => { cancelAnimationFrame(animationFrameId); setup(); draw(); }; setup(); draw(); window.addEventListener("resize", handleResize); return () => { window.removeEventListener("resize", handleResize); cancelAnimationFrame(animationFrameId); }; }, []); return (
{/* Background Canvas for Animation */} {/* Vignette Overlay */}
{/* Main Content */}
×

LFM2 WebGPU

In-browser tool calling, powered by Transformers.js

This demo showcases in-browser tool calling with LFM2, a new generation of hybrid models by{" "} Liquid AI {" "} designed for edge AI and on-device deployment.

Everything runs entirely in your browser with{" "} Transformers.js {" "} and ONNX Runtime Web, meaning no data is sent to a server. It can even run offline!

Select a model and click load to get started.

{isModelDropdownOpen && (
{MODEL_OPTIONS.map((option) => ( ))}
)}
{error && (

Error: {error}

)}
{/* Click-away listener for dropdown */} {isModelDropdownOpen && (
setIsModelDropdownOpen(false)} /> )}
); };