Spaces:
Running
Running
add webgpu availability check
Browse files
src/components/AgenticInterface.tsx
CHANGED
|
@@ -65,6 +65,7 @@ export function AgenticInterface() {
|
|
| 65 |
isLoading={isProcessing || loadingStatus.isLoading}
|
| 66 |
modelReady={loadingStatus.isModelReady}
|
| 67 |
progress={loadingStatus.downloadProgress}
|
|
|
|
| 68 |
/>
|
| 69 |
|
| 70 |
<main className="order-1 md:order-2 flex-1 flex flex-col items-center justify-center p-8 bg-background relative overflow-hidden h-[55vh] md:h-full">
|
|
@@ -73,9 +74,12 @@ export function AgenticInterface() {
|
|
| 73 |
<div className="absolute -bottom-24 -left-24 w-96 h-96 bg-primary/5 rounded-full blur-[120px]" />
|
| 74 |
</div>
|
| 75 |
|
| 76 |
-
<div className="flex flex-col items-center gap-
|
| 77 |
<ColorVisualizer color={squareColor} />
|
| 78 |
-
<ColorControlForm
|
|
|
|
|
|
|
|
|
|
| 79 |
</div>
|
| 80 |
</main>
|
| 81 |
</div>
|
|
|
|
| 65 |
isLoading={isProcessing || loadingStatus.isLoading}
|
| 66 |
modelReady={loadingStatus.isModelReady}
|
| 67 |
progress={loadingStatus.downloadProgress}
|
| 68 |
+
error={loadingStatus.error}
|
| 69 |
/>
|
| 70 |
|
| 71 |
<main className="order-1 md:order-2 flex-1 flex flex-col items-center justify-center p-8 bg-background relative overflow-hidden h-[55vh] md:h-full">
|
|
|
|
| 74 |
<div className="absolute -bottom-24 -left-24 w-96 h-96 bg-primary/5 rounded-full blur-[120px]" />
|
| 75 |
</div>
|
| 76 |
|
| 77 |
+
<div className="flex flex-col items-center gap-6 z-10 w-full max-w-[320px] md:max-w-sm">
|
| 78 |
<ColorVisualizer color={squareColor} />
|
| 79 |
+
<ColorControlForm
|
| 80 |
+
onColorChange={setSquareColor}
|
| 81 |
+
disabled={!!loadingStatus.error}
|
| 82 |
+
/>
|
| 83 |
</div>
|
| 84 |
</main>
|
| 85 |
</div>
|
src/components/ChatSidebar.tsx
CHANGED
|
@@ -14,6 +14,7 @@ type ChatSidebarProps = {
|
|
| 14 |
disabled?: boolean;
|
| 15 |
modelReady?: boolean;
|
| 16 |
progress?: number;
|
|
|
|
| 17 |
};
|
| 18 |
|
| 19 |
export function ChatSidebar({
|
|
@@ -23,9 +24,10 @@ export function ChatSidebar({
|
|
| 23 |
disabled,
|
| 24 |
modelReady = true,
|
| 25 |
progress = 0,
|
|
|
|
| 26 |
}: ChatSidebarProps) {
|
| 27 |
const [inputValue, setInputValue] = useState("");
|
| 28 |
-
const isDisabled = isLoading || disabled;
|
| 29 |
|
| 30 |
const handleSubmit = (e: FormEvent) => {
|
| 31 |
e.preventDefault();
|
|
@@ -68,23 +70,32 @@ export function ChatSidebar({
|
|
| 68 |
</InputGroupButton>
|
| 69 |
</InputGroup>
|
| 70 |
</form>
|
| 71 |
-
{
|
| 72 |
-
<p className="mt-2 text-xs text-
|
| 73 |
-
|
| 74 |
</p>
|
| 75 |
-
)
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
)}
|
| 89 |
</footer>
|
| 90 |
</aside>
|
|
|
|
| 14 |
disabled?: boolean;
|
| 15 |
modelReady?: boolean;
|
| 16 |
progress?: number;
|
| 17 |
+
error?: string;
|
| 18 |
};
|
| 19 |
|
| 20 |
export function ChatSidebar({
|
|
|
|
| 24 |
disabled,
|
| 25 |
modelReady = true,
|
| 26 |
progress = 0,
|
| 27 |
+
error,
|
| 28 |
}: ChatSidebarProps) {
|
| 29 |
const [inputValue, setInputValue] = useState("");
|
| 30 |
+
const isDisabled = isLoading || disabled || !!error;
|
| 31 |
|
| 32 |
const handleSubmit = (e: FormEvent) => {
|
| 33 |
e.preventDefault();
|
|
|
|
| 70 |
</InputGroupButton>
|
| 71 |
</InputGroup>
|
| 72 |
</form>
|
| 73 |
+
{error ? (
|
| 74 |
+
<p className="mt-2 text-xs text-red-500 text-center font-medium">
|
| 75 |
+
{error}
|
| 76 |
</p>
|
| 77 |
+
) : (
|
| 78 |
+
<>
|
| 79 |
+
{!modelReady && !isLoading && (
|
| 80 |
+
<p className="mt-2 text-xs text-muted-foreground text-center">
|
| 81 |
+
Note: The first message will take longer as the model needs to
|
| 82 |
+
be loaded.
|
| 83 |
+
</p>
|
| 84 |
+
)}
|
| 85 |
+
{!modelReady && isLoading && (
|
| 86 |
+
<div className="mt-2 w-full">
|
| 87 |
+
<div className="h-1.5 w-full bg-secondary/50 rounded-full overflow-hidden">
|
| 88 |
+
<div
|
| 89 |
+
className="h-full bg-primary transition-all duration-300 ease-out"
|
| 90 |
+
style={{ width: `${progress}%` }}
|
| 91 |
+
/>
|
| 92 |
+
</div>
|
| 93 |
+
<p className="text-[10px] text-muted-foreground text-center mt-1">
|
| 94 |
+
Loading model... {Math.round(progress)}%
|
| 95 |
+
</p>
|
| 96 |
+
</div>
|
| 97 |
+
)}
|
| 98 |
+
</>
|
| 99 |
)}
|
| 100 |
</footer>
|
| 101 |
</aside>
|
src/hooks/useFunctionCalling.ts
CHANGED
|
@@ -23,6 +23,14 @@ export function useFunctionCalling() {
|
|
| 23 |
const [isProcessing, setIsProcessing] = useState(false);
|
| 24 |
|
| 25 |
useEffect(() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
const worker = new Worker(new URL("../worker.ts", import.meta.url), {
|
| 27 |
type: "module",
|
| 28 |
});
|
|
|
|
| 23 |
const [isProcessing, setIsProcessing] = useState(false);
|
| 24 |
|
| 25 |
useEffect(() => {
|
| 26 |
+
if (!("gpu" in navigator)) {
|
| 27 |
+
setLoadingStatus((prev) => ({
|
| 28 |
+
...prev,
|
| 29 |
+
error: "WebGPU is not available in your browser.",
|
| 30 |
+
}));
|
| 31 |
+
return;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
const worker = new Worker(new URL("../worker.ts", import.meta.url), {
|
| 35 |
type: "module",
|
| 36 |
});
|