| | |
| | | import React from "react"; |
| | | import { |
| | | Edit, |
| | | SimpleForm, |
| | | TextInput, |
| | | NumberInput, |
| | | SaveButton, |
| | | SelectInput, |
| | | Toolbar, |
| | | DeleteButton, |
| | | } from 'react-admin'; |
| | | import { Stack, Grid, Typography } from '@mui/material'; |
| | | import { EDIT_MODE } from '@/config/setting'; |
| | | import EditBaseAside from "@/page/components/EditBaseAside"; |
| | | import CustomerTopToolBar from "@/page/components/EditTopToolBar"; |
| | | import MemoInput from "@/page/components/MemoInput"; |
| | | import StatusSelectInput from "@/page/components/StatusSelectInput"; |
| | | |
| | | const sceneChoices = [ |
| | | { id: 'general_chat', name: '通用对话' }, |
| | | { id: 'system_diagnose', name: '系统诊断' }, |
| | | ]; |
| | | Edit, |
| | | SaveButton, |
| | | SimpleForm, |
| | | Toolbar, |
| | | } from "react-admin"; |
| | | import AiPromptForm from "./AiPromptForm"; |
| | | |
| | | const FormToolbar = () => ( |
| | | <Toolbar sx={{ justifyContent: 'space-between' }}> |
| | | <Toolbar sx={{ justifyContent: "space-between" }}> |
| | | <SaveButton /> |
| | | <DeleteButton mutationMode="optimistic" /> |
| | | <DeleteButton mutationMode="pessimistic" /> |
| | | </Toolbar> |
| | | ); |
| | | |
| | | const AiPromptEdit = () => ( |
| | | <Edit redirect="list" mutationMode={EDIT_MODE} actions={<CustomerTopToolBar />} aside={<EditBaseAside />}> |
| | | <SimpleForm shouldUnregister warnWhenUnsavedChanges toolbar={<FormToolbar />} mode="onTouched"> |
| | | <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> |
| | | <Grid item xs={12} md={8}> |
| | | <Typography variant="h6" gutterBottom>主要</Typography> |
| | | <Stack direction='row' gap={2}> |
| | | <SelectInput source="sceneCode" label="场景" choices={sceneChoices} /> |
| | | <TextInput source="templateName" label="模板名称" /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <NumberInput source="versionNo" label="版本号" /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput source="basePrompt" label="基础提示词" fullWidth multiline minRows={4} /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput source="toolPrompt" label="工具提示词" fullWidth multiline minRows={4} /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput source="outputPrompt" label="输出提示词" fullWidth multiline minRows={4} /> |
| | | </Stack> |
| | | </Grid> |
| | | <Grid item xs={12} md={4}> |
| | | <Typography variant="h6" gutterBottom>通用</Typography> |
| | | <StatusSelectInput /> |
| | | <MemoInput /> |
| | | </Grid> |
| | | </Grid> |
| | | <Edit redirect="list" mutationMode="pessimistic"> |
| | | <SimpleForm warnWhenUnsavedChanges toolbar={<FormToolbar />}> |
| | | <AiPromptForm /> |
| | | </SimpleForm> |
| | | </Edit> |
| | | ) |
| | | ); |
| | | |
| | | export default AiPromptEdit; |