import React, { useCallback } from "react"; import { ModelStatus, ModelStatusComponent } from "../ModelStatusComponent"; import ModelActionMenu from "../ModelActionMenu"; import { useAtomValue } from "jotai"; import ModelActionButton, { ModelActionType } from "../ModelActionButton"; import useStartStopModel from "@/_hooks/useStartStopModel"; import useDeleteModel from "@/_hooks/useDeleteModel"; import { AssistantModel } from "@/_models/AssistantModel"; import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom"; import { toGigabytes } from "@/_utils/converter"; type Props = { model: AssistantModel; }; const ModelRow: React.FC = ({ model }) => { const { startModel, stopModel } = useStartStopModel(); const activeModel = useAtomValue(activeAssistantModelAtom); const { deleteModel } = useDeleteModel(); let status = ModelStatus.Installed; if (activeModel && activeModel.id === model.id) { status = ModelStatus.Active; } let actionButtonType = ModelActionType.Start; if (activeModel && activeModel.id === model.id) { actionButtonType = ModelActionType.Stop; } const onModelActionClick = (action: ModelActionType) => { if (action === ModelActionType.Start) { startModel(model.id); } else { stopModel(model.id); } }; const onDeleteClick = useCallback(() => { deleteModel(model); }, [model]); return ( {model.name} {model.version}
GGUF
{toGigabytes(model.size)} ); }; export default ModelRow;