Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { useContextSizeApproval } from '@/hooks/useModelContextApproval'
import { useTranslation } from '@/i18n'
export default function OutOfContextPromiseModal() {
const { t } = useTranslation()
const { isModalOpen, modalProps, setModalOpen } = useContextSizeApproval()
if (!modalProps) {
return null
}
const { onApprove, onDeny } = modalProps
const handleContextLength = () => {
onApprove('ctx_len')
}
const handleContextShift = () => {
onApprove('context_shift')
}
const handleDialogOpen = (open: boolean) => {
setModalOpen(open)
if (!open) {
onDeny()
}
}
return (
<Dialog open={isModalOpen} onOpenChange={handleDialogOpen}>
<DialogContent
showCloseButton={false}
onInteractOutside={(e) => e.preventDefault()}
>
<DialogHeader>
<DialogTitle>{t('model-errors:title')}</DialogTitle>
</DialogHeader>
<DialogDescription>
{t('model-errors:description')}
<br />
<br />
{t('model-errors:increaseContextSizeDescription')}
</DialogDescription>
<DialogFooter className="flex gap-2">
<Button
variant="ghost"
size="sm"
className="bg-transparent border"
onClick={() => {
handleContextShift()
}}
>
{t('model-errors:truncateInput')}
</Button>
<Button
autoFocus
size="sm"
onClick={() => {
handleContextLength()
}}
>
<span className="text-muted-foreground">
{t('model-errors:increaseContextSize')}
</span>
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}