import type { TrainProgress } from '@/service/train'; import type { IStepOutputInfo } from '../trainExposureModel'; import TrainExposureModel from '../trainExposureModel'; import { useState } from 'react'; import classNames from 'classnames'; interface TrainingProgressProps { trainingProgress: TrainProgress; status: string; } const descriptionMap = [ 'At this stage, we obtain the foundational model that will serve as the starting point for your Second Me. This base structure is a blank slate, ready to be shaped and enriched with your personal data, acting as the vessel that will eventually carry your unique presence.', "This step starts by processing and organizing your memories into a structured digital format that forms the groundwork for your Second Me. We break down your life experiences into smaller, meaningful pieces, encode them systematically, and extract essential insights to create a solid base. It's the first move toward building an entity that reflects your past and present.", "Here, we take the fragments of your memories and weave them into a complete, flowing biography that captures your essence. This process connects the dots between your experiences, shaping them into a coherent story that defines who you are. It's like crafting the blueprint of a new being born from your life's journey.", "To enable your Second Me to understand you fully, we create specialized training data tailored to your unique profile. This step lays the groundwork for it to grasp your preferences, identity, and knowledge accurately, ensuring the entity we're constructing can think and respond in ways that feel authentic to you.", 'Finally, we train the core model with your specific memories, traits, and preferences, blending them seamlessly into its framework. This step transforms the model into a living representation of you, merging technology with your individuality to create a Second Me that feels real and true to your essence.' ]; const TrainingProgress = (props: TrainingProgressProps) => { const { trainingProgress, status } = props; const [stepOutputInfo, setStepOutputInfo] = useState({} as IStepOutputInfo); const formatUnderscoreToName = (_str: string) => { const str = _str || ''; return str .split('_') .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); }; const formatToUnderscore = (str: string): string => { if (!str) return ''; return str.toLowerCase().replace(/\s+/g, '_'); }; const trainingStages = trainingProgress.stages.map((stage, index) => { return { ...stage, description: descriptionMap[index] }; }); return (

Training Progress (may take long with more data and larger model)

{status === 'trained' && ( Training Complete )}
{/* Overall Progress */}
Overall Progress {Math.round(trainingProgress.overall_progress)}%
{/* All Training Stages */}

Training Stages

{trainingStages.map((stage) => { const stageStatus = stage.status; const progress = stage.progress; // Handle NaN case const displayProgress = isNaN(progress) ? 0 : progress; const isCurrentStage = formatUnderscoreToName(trainingProgress.current_stage) == stage.name; return (
{stageStatus === 'completed' ? (
) : stageStatus === 'in_progress' ? (
) : (
)}
{stage.name} {isCurrentStage && stage.current_step && ( {formatUnderscoreToName(stage.current_step)} )}
`; document.body.appendChild(modal); modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; }} title="Learn more about this stage" >
{Math.round(displayProgress)}%
0 ? 'bg-blue-300' : 'bg-gray-200' }`} style={{ width: `${displayProgress}%` }} />
{/* Step list */}
{stage.steps.length > 0 ? (
{stage.steps.map((step, stepIndex) => (
{step.completed ? (
) : stage.current_step && formatUnderscoreToName(stage.current_step) == step.name ? (
) : (
)}
{step.name} {step.completed && step.have_output && ( { setStepOutputInfo({ stepName: formatToUnderscore(step.name), path: step.path }); }} > View Resources )}
))}
) : stageStatus !== 'pending' ? (
Processing...
) : null}
); })}
setStepOutputInfo({} as IStepOutputInfo)} stepOutputInfo={stepOutputInfo} />
); }; export default TrainingProgress;