Spaces:
Sleeping
Sleeping
File size: 2,792 Bytes
fc01079 | 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | import { useState } from "react";
import {
Box,
Button,
Chip,
Paper,
Stack,
TextField,
Typography,
} from "@mui/material";
import RocketLaunchRoundedIcon from "@mui/icons-material/RocketLaunchRounded";
interface Props {
onSubmit: (input: string) => void;
disabled?: boolean;
}
const SAMPLES = [
{ label: "Llama 1B", value: "TinyLlama/TinyLlama-1.1B-Chat-v1.0" },
{ label: "Qwen2.5 0.5B", value: "Qwen/Qwen2.5-0.5B-Instruct" },
{ label: "GPT-2", value: "gpt2" },
{ label: "DistilBERT", value: "distilbert-base-uncased" },
{ label: "ViT", value: "google/vit-base-patch16-224" },
{ label: "T5 small", value: "google-t5/t5-small" },
];
export function ModelInput({ onSubmit, disabled }: Props) {
const [value, setValue] = useState("TinyLlama/TinyLlama-1.1B-Chat-v1.0");
return (
<Paper
elevation={0}
sx={{
p: { xs: 3, md: 5 },
maxWidth: 720,
mx: "auto",
mt: { xs: 4, md: 10 },
textAlign: "center",
background:
"radial-gradient(120% 100% at 50% 0%, rgba(124,92,255,0.15) 0%, rgba(17,26,48,0.0) 70%)",
}}
>
<Typography variant="h4" fontWeight={800} sx={{ letterSpacing: -0.5 }}>
Visualize any Hugging Face model
</Typography>
<Typography variant="body2" color="text.secondary" sx={{ mt: 1.5 }}>
Paste a Hugging Face URL or repo id. Reads only the safetensors header
+ the model's source — no weights, no backend, no wait queue.
</Typography>
<Box
component="form"
onSubmit={(e) => {
e.preventDefault();
if (value.trim()) onSubmit(value.trim());
}}
sx={{ mt: 4, display: "flex", gap: 1.5, flexWrap: "wrap" }}
>
<TextField
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="meta-llama/Llama-3.2-1B or https://huggingface.co/..."
fullWidth
sx={{ flex: 1, minWidth: 240 }}
disabled={disabled}
/>
<Button
type="submit"
variant="contained"
size="large"
disabled={disabled || !value.trim()}
startIcon={<RocketLaunchRoundedIcon />}
>
Visualize
</Button>
</Box>
<Stack
direction="row"
spacing={1}
sx={{ mt: 3, justifyContent: "center", flexWrap: "wrap", rowGap: 1 }}
>
{SAMPLES.map((s) => (
<Chip
key={s.value}
label={s.label}
variant="outlined"
clickable
onClick={() => {
setValue(s.value);
onSubmit(s.value);
}}
sx={{ borderColor: "rgba(155,180,255,0.25)" }}
/>
))}
</Stack>
</Paper>
);
}
|