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: '',
other: '',
model_mapping: '',
system_prompt: '',
models: [],
auto_ban: 1,
groups: ['default']
@@ -304,7 +305,7 @@ const EditChannel = (props) => {
width={isMobile() ? '100%' : 600}
>
<Spin spinning={loading}>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>类型</Typography.Text>
</div>
<Select
@@ -313,12 +314,12 @@ const EditChannel = (props) => {
optionList={CHANNEL_OPTIONS}
value={inputs.type}
onChange={value => handleInputChange('type', value)}
style={{width: '50%'}}
style={{ width: '50%' }}
/>
{
inputs.type === 3 && (
<>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Banner type={"warning"} description={
<>
注意<strong>模型部署名称必须和模型名称保持一致</strong> One API
@@ -329,7 +330,7 @@ const EditChannel = (props) => {
}>
</Banner>
</div>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>AZURE_OPENAI_ENDPOINT</Typography.Text>
</div>
<Input
@@ -342,7 +343,7 @@ const EditChannel = (props) => {
value={inputs.base_url}
autoComplete='new-password'
/>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>默认 API 版本</Typography.Text>
</div>
<Input
@@ -361,7 +362,7 @@ const EditChannel = (props) => {
{
inputs.type === 8 && (
<>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>Base URL</Typography.Text>
</div>
<Input
@@ -376,7 +377,7 @@ const EditChannel = (props) => {
</>
)
}
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>名称</Typography.Text>
</div>
<Input
@@ -389,7 +390,7 @@ const EditChannel = (props) => {
value={inputs.name}
autoComplete='new-password'
/>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>分组</Typography.Text>
</div>
<Select
@@ -410,7 +411,7 @@ const EditChannel = (props) => {
{
inputs.type === 18 && (
<>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>模型版本</Typography.Text>
</div>
<Input
@@ -428,7 +429,7 @@ const EditChannel = (props) => {
{
inputs.type === 21 && (
<>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>知识库 ID</Typography.Text>
</div>
<Input
@@ -444,7 +445,7 @@ const EditChannel = (props) => {
</>
)
}
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>模型</Typography.Text>
</div>
<Select
@@ -460,7 +461,7 @@ const EditChannel = (props) => {
autoComplete='new-password'
optionList={modelOptions}
/>
<div style={{lineHeight: '40px', marginBottom: '12px'}}>
<div style={{ lineHeight: '40px', marginBottom: '12px' }}>
<Space>
<Button type='primary' onClick={() => {
handleInputChange('models', basicModels);
@@ -483,7 +484,7 @@ const EditChannel = (props) => {
}}
/>
</div>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>模型重定向</Typography.Text>
</div>
<TextArea
@@ -496,6 +497,19 @@ const EditChannel = (props) => {
value={inputs.model_mapping}
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={{
color: 'rgba(var(--semi-blue-5), 1)',
userSelect: 'none',
@@ -507,7 +521,7 @@ const EditChannel = (props) => {
}>
填入模板
</Typography.Text>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>密钥</Typography.Text>
</div>
{
@@ -521,7 +535,7 @@ const EditChannel = (props) => {
handleInputChange('key', value)
}}
value={inputs.key}
style={{minHeight: 150, fontFamily: 'JetBrains Mono, Consolas'}}
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
autoComplete='new-password'
/>
:
@@ -537,7 +551,7 @@ const EditChannel = (props) => {
autoComplete='new-password'
/>
}
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>组织</Typography.Text>
</div>
<Input
@@ -549,7 +563,7 @@ const EditChannel = (props) => {
}}
value={inputs.openai_organization}
/>
<div style={{marginTop: 10, display: 'flex'}}>
<div style={{ marginTop: 10, display: 'flex' }}>
<Space>
<Checkbox
name='auto_ban'
@@ -568,7 +582,7 @@ const EditChannel = (props) => {
{
!isEdit && (
<div style={{marginTop: 10, display: 'flex'}}>
<div style={{ marginTop: 10, display: 'flex' }}>
<Space>
<Checkbox
checked={batch}
@@ -584,7 +598,7 @@ const EditChannel = (props) => {
{
inputs.type !== 3 && inputs.type !== 8 && inputs.type !== 22 && (
<>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>代理</Typography.Text>
</div>
<Input
@@ -603,7 +617,7 @@ const EditChannel = (props) => {
{
inputs.type === 22 && (
<>
<div style={{marginTop: 10}}>
<div style={{ marginTop: 10 }}>
<Typography.Text strong>私有部署地址</Typography.Text>
</div>
<Input

View File

@@ -595,6 +595,28 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
<FormHelperText id="helper-tex-channel-model_mapping-label"> {inputPrompt.model_mapping} </FormHelperText>
)}
</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>
<Button onClick={onCancel}>取消</Button>
<Button disableElevation disabled={isSubmitting} type="submit" variant="contained" color="primary">

View File

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