"use client"; import type { AutoFormInputComponentProps } from "../ui/auto-form/types"; import { LoadingIcon } from "@/components/LoadingIcon"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/utils"; import { Check, ChevronsUpDown } from "lucide-react"; import * as React from "react"; import { useRef } from "react"; import { useDebouncedCallback } from "use-debounce"; import { z } from "zod"; const Model = z.object({ name: z.string(), type: z.string(), base: z.string(), save_path: z.string(), description: z.string(), reference: z.string(), filename: z.string(), url: z.string(), }); export const CivitalModelSchema = z.object({ items: z.array( z.object({ id: z.number(), name: z.string(), description: z.string(), type: z.string(), // poi: z.boolean(), // nsfw: z.boolean(), // allowNoCredit: z.boolean(), // allowCommercialUse: z.string(), // allowDerivatives: z.boolean(), // allowDifferentLicense: z.boolean(), // stats: z.object({ // downloadCount: z.number(), // favoriteCount: z.number(), // commentCount: z.number(), // ratingCount: z.number(), // rating: z.number(), // tippedAmountCount: z.number(), // }), creator: z .object({ username: z.string().nullable(), image: z.string().nullable().default(null), }) .nullable(), tags: z.array(z.string()), modelVersions: z.array( z.object({ id: z.number(), modelId: z.number(), name: z.string(), createdAt: z.string(), updatedAt: z.string(), status: z.string(), publishedAt: z.string(), trainedWords: z.array(z.unknown()), trainingStatus: z.string().nullable(), trainingDetails: z.string().nullable(), baseModel: z.string(), baseModelType: z.string().nullable(), earlyAccessTimeFrame: z.number(), description: z.string().nullable(), vaeId: z.number().nullable(), stats: z.object({ downloadCount: z.number(), ratingCount: z.number(), rating: z.number(), }), files: z.array( z.object({ id: z.number(), sizeKB: z.number(), name: z.string(), type: z.string(), // metadata: z.object({ // fp: z.string().nullable().optional(), // size: z.string().nullable().optional(), // format: z.string().nullable().optional(), // }), // pickleScanResult: z.string(), // pickleScanMessage: z.string(), // virusScanResult: z.string(), // virusScanMessage: z.string().nullable(), // scannedAt: z.string(), // hashes: z.object({ // AutoV1: z.string().nullable().optional(), // AutoV2: z.string().nullable().optional(), // SHA256: z.string().nullable().optional(), // CRC32: z.string().nullable().optional(), // BLAKE3: z.string().nullable().optional(), // }), downloadUrl: z.string(), // primary: z.boolean().default(false), }) ), images: z.array( z.object({ id: z.number(), url: z.string(), nsfw: z.string(), width: z.number(), height: z.number(), hash: z.string(), type: z.string(), metadata: z.object({ hash: z.string(), width: z.number(), height: z.number(), }), meta: z.any(), }) ), downloadUrl: z.string(), }) ), }) ), metadata: z.object({ totalItems: z.number(), currentPage: z.number(), pageSize: z.number(), totalPages: z.number(), nextPage: z.string().optional(), }), }); const ModelList = z.array(Model); export const ModelListWrapper = z.object({ models: ModelList, }); export function ModelPickerView({ field, }: Pick) { return ( Models (ComfyUI Manager & Civitai)
{/* {field.value.length} selected */} {field.value && (