import React, { useCallback } from 'react' import { ModelStatus, ModelStatusComponent } from '../ModelStatusComponent' import { useAtomValue } from 'jotai' import ModelActionButton, { ModelActionType } from '../ModelActionButton' import useStartStopModel from '@hooks/useStartStopModel' import useDeleteModel from '@hooks/useDeleteModel' import { activeAssistantModelAtom, stateModel } 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() const { loading, model: currentModelState } = useAtomValue(stateModel) 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) // eslint-disable-next-line react-hooks/exhaustive-deps }, [model]) return ( {model.name} v{model.version}
GGUF
{toGigabytes(model.size)} ) } export default ModelRow