"use client"; import { useState, useEffect } from "react"; import { ArrowUp, Cpu, Database, Plus, Loader2, ChevronRight } from "lucide-react"; import Navbar from "@/components/Navbar"; import Footer from "@/components/Footer"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Badge } from "@/components/ui/badge"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Combobox } from "@/components/ui/combobox"; import { toast } from "@/components/ui/toaster"; interface DistillationRequest { id: string; sourceDataset: string; studentModel: string; submitterName?: string; additionalNotes: string; upvotes: number; createdAt: string; status: "pending" | "in_progress" | "completed"; } interface DatasetRequest { id: string; sourceModel: string; submitterName?: string; datasetSize: string; reasoningDepth: string; topics: string[]; additionalNotes: string; upvotes: number; createdAt: string; status: "pending" | "in_progress" | "completed"; } interface TeichAIDataset { id: string; name: string; } interface OpenRouterModel { id: string; name: string; } interface HuggingFaceModel { id: string; name: string; } const STUDENT_MODELS = [ "Qwen3-4B", "Qwen3-4B-Thinking-2507", "Qwen3-4B-Instruct-2507", "Qwen3-8B", "Qwen3-14B", "Qwen3-30B-A3B-Thinking-2507", "Qwen3-32B", "Nemotron-Cascade-14B-Thinking", "Nemotron-Cascade-8B-Thinking", "Other", ]; const SOURCE_MODEL_OTHER_HF = "Other (HuggingFace)"; const REASONING_DEPTHS = ["low", "medium", "high"]; const DATASET_SIZES = ["100x", "250x", "500x", "1000x", "3000x", "11000x"]; const TOPICS = [ "Coding", "Math", "Science", "Web Development", "Data Science", "Machine Learning", "Creative Writing", "Reasoning", "Logic", "General Knowledge", ]; export default function Home() { const router = useRouter(); const [distillationRequests, setDistillationRequests] = useState([]); const [datasetRequests, setDatasetRequests] = useState([]); const [loading, setLoading] = useState(true); const [submitting, setSubmitting] = useState(false); const [showDistillForm, setShowDistillForm] = useState(false); const [showDatasetForm, setShowDatasetForm] = useState(false); // External data const [teichaiDatasets, setTeichaiDatasets] = useState([]); const [openrouterModels, setOpenrouterModels] = useState([]); const [loadingDatasets, setLoadingDatasets] = useState(false); const [loadingModels, setLoadingModels] = useState(false); const [huggingfaceModels, setHuggingfaceModels] = useState([]); const [hfModelQuery, setHfModelQuery] = useState(""); const [loadingHfModels, setLoadingHfModels] = useState(false); const [distillHuggingfaceModels, setDistillHuggingfaceModels] = useState([]); const [distillHfModelQuery, setDistillHfModelQuery] = useState(""); const [loadingDistillHfModels, setLoadingDistillHfModels] = useState(false); // Distillation form state const [sourceDataset, setSourceDataset] = useState(""); const [sourceDatasetOther, setSourceDatasetOther] = useState(""); const [studentModel, setStudentModel] = useState(""); const [studentModelOther, setStudentModelOther] = useState(""); const [distillSubmitterName, setDistillSubmitterName] = useState(""); const [distillNotes, setDistillNotes] = useState(""); // Dataset form state const [sourceModel, setSourceModel] = useState(""); const [sourceModelOther, setSourceModelOther] = useState(""); const [datasetSubmitterName, setDatasetSubmitterName] = useState(""); const [datasetSize, setDatasetSize] = useState("250x"); const [reasoningDepth, setReasoningDepth] = useState("high"); const [selectedTopics, setSelectedTopics] = useState([]); const [datasetNotes, setDatasetNotes] = useState(""); useEffect(() => { fetchRequests(); fetchTeichaiDatasets(); fetchOpenrouterModels(); }, []); useEffect(() => { let cancelled = false; const q = hfModelQuery.trim(); const timer = setTimeout(async () => { setLoadingHfModels(true); try { const res = await fetch(`/api/huggingface-models?q=${encodeURIComponent(q)}&limit=20`); const data = await res.json(); if (!cancelled) { setHuggingfaceModels(Array.isArray(data) ? data : []); } } catch (error) { console.error("Error fetching Hugging Face models:", error); if (!cancelled) { setHuggingfaceModels([]); } } finally { if (!cancelled) { setLoadingHfModels(false); } } }, 250); return () => { cancelled = true; clearTimeout(timer); }; }, [hfModelQuery]); useEffect(() => { let cancelled = false; const q = distillHfModelQuery.trim(); const timer = setTimeout(async () => { setLoadingDistillHfModels(true); try { const res = await fetch(`/api/huggingface-models?q=${encodeURIComponent(q)}&limit=20`); const data = await res.json(); if (!cancelled) { setDistillHuggingfaceModels(Array.isArray(data) ? data : []); } } catch (error) { console.error("Error fetching Hugging Face models:", error); if (!cancelled) { setDistillHuggingfaceModels([]); } } finally { if (!cancelled) { setLoadingDistillHfModels(false); } } }, 250); return () => { cancelled = true; clearTimeout(timer); }; }, [distillHfModelQuery]); async function fetchRequests() { try { const [distillRes, datasetRes] = await Promise.all([ fetch("/api/distillation"), fetch("/api/dataset"), ]); const distillData = await distillRes.json(); const datasetData = await datasetRes.json(); setDistillationRequests(Array.isArray(distillData) ? distillData : []); setDatasetRequests(Array.isArray(datasetData) ? datasetData : []); } catch (error) { console.error("Error fetching requests:", error); } finally { setLoading(false); } } async function fetchTeichaiDatasets() { setLoadingDatasets(true); try { const res = await fetch("/api/teichai-datasets"); const data = await res.json(); setTeichaiDatasets(Array.isArray(data) ? data : []); } catch (error) { console.error("Error fetching TeichAI datasets:", error); } finally { setLoadingDatasets(false); } } async function fetchOpenrouterModels() { setLoadingModels(true); try { const res = await fetch("/api/openrouter-models"); const data = await res.json(); setOpenrouterModels(Array.isArray(data) ? data : []); } catch (error) { console.error("Error fetching OpenRouter models:", error); } finally { setLoadingModels(false); } } async function handleDistillSubmit(e: React.FormEvent) { e.preventDefault(); const resolvedSourceDataset = sourceDataset === "Other" ? sourceDatasetOther.trim() : sourceDataset; const resolvedStudentModel = studentModel === "Other" ? studentModelOther.trim() : studentModel; const resolvedSubmitterName = distillSubmitterName.trim(); if (!resolvedSourceDataset || !resolvedStudentModel) { toast({ title: "Error", description: "Please fill in required fields", variant: "destructive" }); return; } setSubmitting(true); try { const res = await fetch("/api/distillation", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ sourceDataset: resolvedSourceDataset, studentModel: resolvedStudentModel, submitterName: resolvedSubmitterName || undefined, additionalNotes: distillNotes, }), }); if (res.ok) { toast({ title: "Success", description: "Distillation request submitted!" }); setSourceDataset(""); setSourceDatasetOther(""); setStudentModel(""); setStudentModelOther(""); setDistillHfModelQuery(""); setDistillHuggingfaceModels([]); setDistillSubmitterName(""); setDistillNotes(""); setShowDistillForm(false); fetchRequests(); } else { throw new Error("Failed to submit"); } } catch (error) { toast({ title: "Error", description: "Failed to submit request", variant: "destructive" }); } finally { setSubmitting(false); } } async function handleDatasetSubmit(e: React.FormEvent) { e.preventDefault(); const resolvedSourceModel = sourceModel === SOURCE_MODEL_OTHER_HF ? sourceModelOther.trim() : sourceModel; const resolvedSubmitterName = datasetSubmitterName.trim(); if (!resolvedSourceModel) { toast({ title: "Error", description: "Please select a source model", variant: "destructive" }); return; } setSubmitting(true); try { const res = await fetch("/api/dataset", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ sourceModel: resolvedSourceModel, submitterName: resolvedSubmitterName || undefined, datasetSize, reasoningDepth, topics: selectedTopics, additionalNotes: datasetNotes, }), }); if (res.ok) { toast({ title: "Success", description: "Dataset request submitted!" }); setSourceModel(openrouterModels[0]?.id || ""); setSourceModelOther(""); setHfModelQuery(""); setHuggingfaceModels([]); setDatasetSubmitterName(""); setDatasetSize("250x"); setReasoningDepth("high"); setSelectedTopics([]); setDatasetNotes(""); setShowDatasetForm(false); fetchRequests(); } else { throw new Error("Failed to submit"); } } catch (error) { toast({ title: "Error", description: "Failed to submit request", variant: "destructive" }); } finally { setSubmitting(false); } } async function handleUpvote(type: "distillation" | "dataset", id: string) { try { const endpoint = type === "distillation" ? "/api/distillation" : "/api/dataset"; const res = await fetch(endpoint, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id }), }); const data = await res.json(); if (!res.ok) { if (res.status === 404) { toast({ title: "Not found", description: "This request no longer exists", variant: "destructive" }); return; } toast({ title: "Error", description: data?.error || "Failed to vote", variant: "destructive" }); return; } if (type === "distillation") { setDistillationRequests((prev) => prev.map((r) => (r.id === id ? { ...r, upvotes: data.upvotes } : r)) ); } else { setDatasetRequests((prev) => prev.map((r) => (r.id === id ? { ...r, upvotes: data.upvotes } : r)) ); } if (data.action === "unvoted") { toast({ title: "Vote removed", description: "Your vote has been removed" }); } else { toast({ title: "Voted!", description: "Your vote has been recorded" }); } } catch (error) { toast({ title: "Error", description: "Failed to vote", variant: "destructive" }); } } function toggleTopic(topic: string) { setSelectedTopics((prev) => prev.includes(topic) ? prev.filter((t) => t !== topic) : [...prev, topic] ); } function getStatusBadge(status: string) { switch (status) { case "completed": return Completed; case "in_progress": return In Progress; default: return Pending; } } function formatDate(dateStr: string) { return new Date(dateStr).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", }); } function goToDiscussion(type: "distillation" | "dataset", id: string) { router.push(`/requests/${type}/${id}`); } return (
{/* Hero */}

Community Requests

Request Model Distillations & Datasets

Submit your requests for new distilled models or reasoning datasets. Vote on requests from other community members to help us prioritize what to build next.

{/* Main Content */}
Model Distillation Dataset {/* Distillation Tab */}

Distillation Requests

{showDistillForm && ( Request a Distilled Model Select one of our existing datasets to distill into a student model
{ setSourceDataset(v); if (v !== "Other") setSourceDatasetOther(""); }} placeholder="Select a TeichAI dataset" searchPlaceholder="Search datasets..." emptyMessage="No datasets found" loading={loadingDatasets} />
{sourceDataset === "Other" && (
setSourceDatasetOther(e.target.value)} placeholder="Type the dataset name" />
)} {studentModel === "Other" && (
)}
setDistillSubmitterName(e.target.value)} placeholder="Your name (optional)" />