forked from QuantumNous/new-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissing-models-confirmation-dialog.tsx
More file actions
103 lines (93 loc) 路 3.42 KB
/
Copy pathmissing-models-confirmation-dialog.tsx
File metadata and controls
103 lines (93 loc) 路 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useTranslation } from 'react-i18next'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { Button } from '@/components/ui/button'
export type MissingModelsAction = 'cancel' | 'submit' | 'add'
type MissingModelsConfirmationDialogProps = {
open: boolean
missingModels: string[]
onConfirm: (action: MissingModelsAction) => void
onOpenChange?: (open: boolean) => void
}
/**
* Confirmation dialog shown when models in model_mapping are missing from the models list
* Provides three options:
* 1. Cancel - Go back to edit
* 2. Submit - Submit anyway without adding missing models
* 3. Add - Automatically add missing models and submit
*/
export function MissingModelsConfirmationDialog({
open,
missingModels,
onConfirm,
onOpenChange,
}: MissingModelsConfirmationDialogProps) {
const { t } = useTranslation()
const handleOpenChange = (newOpen: boolean) => {
if (!newOpen) {
onConfirm('cancel')
}
onOpenChange?.(newOpen)
}
return (
<AlertDialog open={open} onOpenChange={handleOpenChange}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t('Models not in list, may fail to invoke')}
</AlertDialogTitle>
<AlertDialogDescription
render={<div className='space-y-3 text-sm' />}
>
<div>
{t(
'The following models in the model redirect have not been added to the "Models" list and may fail during invocation due to missing available models:'
)}
</div>
<div className='rounded-md bg-red-50 p-2 font-mono text-xs break-all text-red-600 dark:bg-red-950/50 dark:text-red-400'>
{missingModels.join(', ')}
</div>
<div>
{t(
'You can manually add them in "Custom Model Names", click "Fill" and then submit, or use the operations below to handle automatically.'
)}
</div>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter className='flex-col gap-2 sm:flex-row'>
<AlertDialogCancel onClick={() => onConfirm('cancel')}>
{t('Go back and edit')}
</AlertDialogCancel>
<Button variant='secondary' onClick={() => onConfirm('submit')}>
{t('Submit directly')}
</Button>
<AlertDialogAction onClick={() => onConfirm('add')}>
{t('Add and submit')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}