okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
fcb0c2d0e
main
1import { tr } from './i18n' ; 2import { sendOversized , startNewChat , summarizeAndContinue } from './store' ; 3 4/** 5* What the error card of a chat offers when the model's window is the problem. A conversation that no longer fits can be summarised and 6* carried on, or left for a new chat; a single message that is too large can go as a file the assistant reads in parts, or as a shortened 7* preview. "Try the message again" would only fail the same way, so the card never says it for these. 8*/ 9export function contextRecovery ( code :string | undefined ) :{ 10next :string ; 11action ?:string ; 12onRetry ?:() => void ; 13secondary ?:{ label :string ; onClick :() => void }; 14} { 15if ( code === 'CONTEXT_MESSAGE_TOO_LARGE' ) { 16return { 17next :tr ( 'Attach it as a file for the assistant to read in parts, or send a shortened preview.' ), 18action :'Attach as a file' , 19onRetry :() => void sendOversized ( 'file' ), 20secondary :{ label :'Send a shortened preview' , onClick :() => void sendOversized ( 'preview' ) }, 21}; 22} 23if ( code === 'CONTEXT_WINDOW_EXCEEDED' ) { 24return { 25next :tr ( 'Summarize it now and continue, or start a new chat.' ), 26action :'Summarize and continue' , 27onRetry :() => void summarizeAndContinue (), 28secondary :{ label :'Start a new chat' , onClick :() => startNewChat () }, 29}; 30} 31return { next :tr ( 'Try sending the message again.' ) }; 32}