"use client" import * as React from "react" import { ChevronRight, ChevronDown } from "lucide-react" import { Input } from "@/components/ui/input" import { Collapsible, CollapsibleTrigger, CollapsibleContent, } from "@/components/ui/collapsible" export interface SearchOptions { n_docs: number nprobe?: number min_tile_height?: number instruction?: string } interface SearchControlsProps { options: SearchOptions onChange: (options: SearchOptions) => void } export function SearchControls({ options, onChange }: SearchControlsProps) { const [open, setOpen] = React.useState(false) function update(patch: Partial) { onChange({ ...options, ...patch }) } function handleNumber( field: "n_docs" | "nprobe" | "min_tile_height", value: string ) { if (value === "") { if (field === "n_docs") return // n_docs is required update({ [field]: undefined }) return } const num = parseInt(value, 10) if (!isNaN(num) && num > 0) { update({ [field]: num }) } } return ( {open ? ( ) : ( )} Advanced
handleNumber("n_docs", e.target.value)} /> handleNumber("nprobe", e.target.value)} /> handleNumber("min_tile_height", e.target.value)} /> update({ instruction: e.target.value || undefined }) } />
) } function Field({ label, children, className, }: { label: string children: React.ReactNode className?: string }) { return (
{children}
) }