feat: support set system_prompt for theme air & berry

This commit is contained in:
JustSong
2024-11-10 15:09:02 +08:00
parent 6eb0770a89
commit 833fa7ad6f
3 changed files with 278 additions and 240 deletions

View File

@@ -43,6 +43,7 @@ const EditChannel = (props) => {
base_url: '', base_url: '',
other: '', other: '',
model_mapping: '', model_mapping: '',
system_prompt: '',
models: [], models: [],
auto_ban: 1, auto_ban: 1,
groups: ['default'] groups: ['default']
@@ -496,6 +497,19 @@ const EditChannel = (props) => {
value={inputs.model_mapping} value={inputs.model_mapping}
autoComplete='new-password' autoComplete='new-password'
/> />
<div style={{ marginTop: 10 }}>
<Typography.Text strong>系统提示词</Typography.Text>
</div>
<TextArea
placeholder={`此项可选,用于强制设置给定的系统提示词,请配合自定义模型 & 模型重定向使用,首先创建一个唯一的自定义模型名称并在上面填入,之后将该自定义模型重定向映射到该渠道一个原生支持的模型`}
name='system_prompt'
onChange={value => {
handleInputChange('system_prompt', value)
}}
autosize
value={inputs.system_prompt}
autoComplete='new-password'
/>
<Typography.Text style={{ <Typography.Text style={{
color: 'rgba(var(--semi-blue-5), 1)', color: 'rgba(var(--semi-blue-5), 1)',
userSelect: 'none', userSelect: 'none',

View File

@@ -595,6 +595,28 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
<FormHelperText id="helper-tex-channel-model_mapping-label"> {inputPrompt.model_mapping} </FormHelperText> <FormHelperText id="helper-tex-channel-model_mapping-label"> {inputPrompt.model_mapping} </FormHelperText>
)} )}
</FormControl> </FormControl>
<FormControl fullWidth error={Boolean(touched.system_prompt && errors.system_prompt)} sx={{ ...theme.typography.otherInput }}>
{/* <InputLabel htmlFor="channel-model_mapping-label">{inputLabel.model_mapping}</InputLabel> */}
<TextField
multiline
id="channel-system_prompt-label"
label={inputLabel.system_prompt}
value={values.system_prompt}
name="system_prompt"
onBlur={handleBlur}
onChange={handleChange}
aria-describedby="helper-text-channel-system_prompt-label"
minRows={5}
placeholder={inputPrompt.system_prompt}
/>
{touched.system_prompt && errors.system_prompt ? (
<FormHelperText error id="helper-tex-channel-system_prompt-label">
{errors.system_prompt}
</FormHelperText>
) : (
<FormHelperText id="helper-tex-channel-system_prompt-label"> {inputPrompt.system_prompt} </FormHelperText>
)}
</FormControl>
<DialogActions> <DialogActions>
<Button onClick={onCancel}>取消</Button> <Button onClick={onCancel}>取消</Button>
<Button disableElevation disabled={isSubmitting} type="submit" variant="contained" color="primary"> <Button disableElevation disabled={isSubmitting} type="submit" variant="contained" color="primary">

View File

@@ -18,6 +18,7 @@ const defaultConfig = {
other: '其他参数', other: '其他参数',
models: '模型', models: '模型',
model_mapping: '模型映射关系', model_mapping: '模型映射关系',
system_prompt: '系统提示词',
groups: '用户组', groups: '用户组',
config: null config: null
}, },
@@ -30,6 +31,7 @@ const defaultConfig = {
models: '请选择该渠道所支持的模型', models: '请选择该渠道所支持的模型',
model_mapping: model_mapping:
'请输入要修改的模型映射关系格式为api请求模型ID:实际转发给渠道的模型ID使用JSON数组表示例如{"gpt-3.5": "gpt-35"}', '请输入要修改的模型映射关系格式为api请求模型ID:实际转发给渠道的模型ID使用JSON数组表示例如{"gpt-3.5": "gpt-35"}',
system_prompt:"此项可选,用于强制设置给定的系统提示词,请配合自定义模型 & 模型重定向使用,首先创建一个唯一的自定义模型名称并在上面填入,之后将该自定义模型重定向映射到该渠道一个原生支持的模型此项可选,用于强制设置给定的系统提示词,请配合自定义模型 & 模型重定向使用,首先创建一个唯一的自定义模型名称并在上面填入,之后将该自定义模型重定向映射到该渠道一个原生支持的模型",
groups: '请选择该渠道所支持的用户组', groups: '请选择该渠道所支持的用户组',
config: null config: null
}, },