import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" import { Skeleton, Table, Tag, Tooltip, notification, Modal, Input } from "antd" import { bytePerSecondFormatter } from "~libs/byte-formater" import { deleteModel, getAllModels } from "~services/ollama" import dayjs from "dayjs" import relativeTime from "dayjs/plugin/relativeTime" import { useState } from "react" import { useForm } from "@mantine/form" import { Download } from "~icons/Download" import { RotateCcw } from "~icons/RotateCcw" import { Trash } from "~icons/Trash" dayjs.extend(relativeTime) export const ModelsBody = () => { const queryClient = useQueryClient() const [open, setOpen] = useState(false) const form = useForm({ initialValues: { model: "" } }) const { data, status } = useQuery({ queryKey: ["fetchAllModels"], queryFn: getAllModels }) const { mutate: deleteOllamaModel } = useMutation({ mutationFn: deleteModel, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["fetchAllModels"] }) notification.success({ message: "Model Deleted", description: "Model has been deleted successfully" }) }, onError: (error) => { notification.error({ message: "Error", description: error?.message || "Something went wrong" }) } }) const pullModel = async (modelName: string) => { notification.info({ message: "Pulling Model", description: `Pulling ${modelName} model. For more details, check the extension icon.` }) setOpen(false) form.reset() chrome.runtime.sendMessage({ type: "pull_model", modelName }) return true } const { mutate: pullOllamaModel } = useMutation({ mutationFn: pullModel }) return (