|
@@ -6,8 +6,9 @@ import {
|
|
|
isMobile,
|
|
isMobile,
|
|
|
showError,
|
|
showError,
|
|
|
showInfo,
|
|
showInfo,
|
|
|
- showSuccess, showWarning,
|
|
|
|
|
- verifyJSON
|
|
|
|
|
|
|
+ showSuccess,
|
|
|
|
|
+ showWarning,
|
|
|
|
|
+ verifyJSON,
|
|
|
} from '../../helpers';
|
|
} from '../../helpers';
|
|
|
import { CHANNEL_OPTIONS } from '../../constants';
|
|
import { CHANNEL_OPTIONS } from '../../constants';
|
|
|
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
|
|
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
|
|
@@ -22,21 +23,22 @@ import {
|
|
|
Select,
|
|
Select,
|
|
|
TextArea,
|
|
TextArea,
|
|
|
Checkbox,
|
|
Checkbox,
|
|
|
- Banner, Modal
|
|
|
|
|
|
|
+ Banner,
|
|
|
|
|
+ Modal,
|
|
|
} from '@douyinfe/semi-ui';
|
|
} from '@douyinfe/semi-ui';
|
|
|
import { getChannelModels, loadChannelModels } from '../../components/utils.js';
|
|
import { getChannelModels, loadChannelModels } from '../../components/utils.js';
|
|
|
|
|
|
|
|
const MODEL_MAPPING_EXAMPLE = {
|
|
const MODEL_MAPPING_EXAMPLE = {
|
|
|
- 'gpt-3.5-turbo': 'gpt-3.5-turbo-0125'
|
|
|
|
|
|
|
+ 'gpt-3.5-turbo': 'gpt-3.5-turbo-0125',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const STATUS_CODE_MAPPING_EXAMPLE = {
|
|
const STATUS_CODE_MAPPING_EXAMPLE = {
|
|
|
- 400: '500'
|
|
|
|
|
|
|
+ 400: '500',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const REGION_EXAMPLE = {
|
|
const REGION_EXAMPLE = {
|
|
|
- 'default': 'us-central1',
|
|
|
|
|
- 'claude-3-5-sonnet-20240620': 'europe-west1'
|
|
|
|
|
|
|
+ default: 'us-central1',
|
|
|
|
|
+ 'claude-3-5-sonnet-20240620': 'europe-west1',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
function type2secretPrompt(type) {
|
|
function type2secretPrompt(type) {
|
|
@@ -82,7 +84,7 @@ const EditChannel = (props) => {
|
|
|
groups: ['default'],
|
|
groups: ['default'],
|
|
|
priority: 0,
|
|
priority: 0,
|
|
|
weight: 0,
|
|
weight: 0,
|
|
|
- tag: ''
|
|
|
|
|
|
|
+ tag: '',
|
|
|
};
|
|
};
|
|
|
const [batch, setBatch] = useState(false);
|
|
const [batch, setBatch] = useState(false);
|
|
|
const [autoBan, setAutoBan] = useState(true);
|
|
const [autoBan, setAutoBan] = useState(true);
|
|
@@ -98,12 +100,13 @@ const EditChannel = (props) => {
|
|
|
if (name === 'base_url' && value.endsWith('/v1')) {
|
|
if (name === 'base_url' && value.endsWith('/v1')) {
|
|
|
Modal.confirm({
|
|
Modal.confirm({
|
|
|
title: '警告',
|
|
title: '警告',
|
|
|
- content: '不需要在末尾加/v1,New API会自动处理,添加后可能导致请求失败,是否继续?',
|
|
|
|
|
|
|
+ content:
|
|
|
|
|
+ '不需要在末尾加/v1,New API会自动处理,添加后可能导致请求失败,是否继续?',
|
|
|
onOk: () => {
|
|
onOk: () => {
|
|
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
|
|
if (name === 'type') {
|
|
if (name === 'type') {
|
|
@@ -117,7 +120,7 @@ const EditChannel = (props) => {
|
|
|
'mj_blend',
|
|
'mj_blend',
|
|
|
'mj_upscale',
|
|
'mj_upscale',
|
|
|
'mj_describe',
|
|
'mj_describe',
|
|
|
- 'mj_uploads'
|
|
|
|
|
|
|
+ 'mj_uploads',
|
|
|
];
|
|
];
|
|
|
break;
|
|
break;
|
|
|
case 5:
|
|
case 5:
|
|
@@ -137,14 +140,11 @@ const EditChannel = (props) => {
|
|
|
'mj_high_variation',
|
|
'mj_high_variation',
|
|
|
'mj_low_variation',
|
|
'mj_low_variation',
|
|
|
'mj_pan',
|
|
'mj_pan',
|
|
|
- 'mj_uploads'
|
|
|
|
|
|
|
+ 'mj_uploads',
|
|
|
];
|
|
];
|
|
|
break;
|
|
break;
|
|
|
case 36:
|
|
case 36:
|
|
|
- localModels = [
|
|
|
|
|
- 'suno_music',
|
|
|
|
|
- 'suno_lyrics'
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ localModels = ['suno_music', 'suno_lyrics'];
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
localModels = getChannelModels(value);
|
|
localModels = getChannelModels(value);
|
|
@@ -180,7 +180,7 @@ const EditChannel = (props) => {
|
|
|
data.model_mapping = JSON.stringify(
|
|
data.model_mapping = JSON.stringify(
|
|
|
JSON.parse(data.model_mapping),
|
|
JSON.parse(data.model_mapping),
|
|
|
null,
|
|
null,
|
|
|
- 2
|
|
|
|
|
|
|
+ 2,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
setInputs(data);
|
|
setInputs(data);
|
|
@@ -197,7 +197,6 @@ const EditChannel = (props) => {
|
|
|
setLoading(false);
|
|
setLoading(false);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const fetchUpstreamModelList = async (name) => {
|
|
const fetchUpstreamModelList = async (name) => {
|
|
|
// if (inputs['type'] !== 1) {
|
|
// if (inputs['type'] !== 1) {
|
|
|
// showError(t('仅支持 OpenAI 接口格式'));
|
|
// showError(t('仅支持 OpenAI 接口格式'));
|
|
@@ -225,9 +224,9 @@ const EditChannel = (props) => {
|
|
|
const res = await API.post('/api/channel/fetch_models', {
|
|
const res = await API.post('/api/channel/fetch_models', {
|
|
|
base_url: inputs['base_url'],
|
|
base_url: inputs['base_url'],
|
|
|
type: inputs['type'],
|
|
type: inputs['type'],
|
|
|
- key: inputs['key']
|
|
|
|
|
|
|
+ key: inputs['key'],
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (res.data && res.data.success) {
|
|
if (res.data && res.data.success) {
|
|
|
models.push(...res.data.data);
|
|
models.push(...res.data.data);
|
|
|
} else {
|
|
} else {
|
|
@@ -254,7 +253,7 @@ const EditChannel = (props) => {
|
|
|
let res = await API.get(`/api/channel/models`);
|
|
let res = await API.get(`/api/channel/models`);
|
|
|
let localModelOptions = res.data.data.map((model) => ({
|
|
let localModelOptions = res.data.data.map((model) => ({
|
|
|
label: model.id,
|
|
label: model.id,
|
|
|
- value: model.id
|
|
|
|
|
|
|
+ value: model.id,
|
|
|
}));
|
|
}));
|
|
|
setOriginModelOptions(localModelOptions);
|
|
setOriginModelOptions(localModelOptions);
|
|
|
setFullModels(res.data.data.map((model) => model.id));
|
|
setFullModels(res.data.data.map((model) => model.id));
|
|
@@ -263,7 +262,7 @@ const EditChannel = (props) => {
|
|
|
.filter((model) => {
|
|
.filter((model) => {
|
|
|
return model.id.startsWith('gpt-') || model.id.startsWith('text-');
|
|
return model.id.startsWith('gpt-') || model.id.startsWith('text-');
|
|
|
})
|
|
})
|
|
|
- .map((model) => model.id)
|
|
|
|
|
|
|
+ .map((model) => model.id),
|
|
|
);
|
|
);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
showError(error.message);
|
|
showError(error.message);
|
|
@@ -279,8 +278,8 @@ const EditChannel = (props) => {
|
|
|
setGroupOptions(
|
|
setGroupOptions(
|
|
|
res.data.data.map((group) => ({
|
|
res.data.data.map((group) => ({
|
|
|
label: group,
|
|
label: group,
|
|
|
- value: group
|
|
|
|
|
- }))
|
|
|
|
|
|
|
+ value: group,
|
|
|
|
|
+ })),
|
|
|
);
|
|
);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
showError(error.message);
|
|
showError(error.message);
|
|
@@ -293,7 +292,7 @@ const EditChannel = (props) => {
|
|
|
if (!localModelOptions.find((option) => option.label === model)) {
|
|
if (!localModelOptions.find((option) => option.label === model)) {
|
|
|
localModelOptions.push({
|
|
localModelOptions.push({
|
|
|
label: model,
|
|
label: model,
|
|
|
- value: model
|
|
|
|
|
|
|
+ value: model,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -330,7 +329,7 @@ const EditChannel = (props) => {
|
|
|
if (localInputs.base_url && localInputs.base_url.endsWith('/')) {
|
|
if (localInputs.base_url && localInputs.base_url.endsWith('/')) {
|
|
|
localInputs.base_url = localInputs.base_url.slice(
|
|
localInputs.base_url = localInputs.base_url.slice(
|
|
|
0,
|
|
0,
|
|
|
- localInputs.base_url.length - 1
|
|
|
|
|
|
|
+ localInputs.base_url.length - 1,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
if (localInputs.type === 18 && localInputs.other === '') {
|
|
if (localInputs.type === 18 && localInputs.other === '') {
|
|
@@ -348,7 +347,7 @@ const EditChannel = (props) => {
|
|
|
if (isEdit) {
|
|
if (isEdit) {
|
|
|
res = await API.put(`/api/channel/`, {
|
|
res = await API.put(`/api/channel/`, {
|
|
|
...localInputs,
|
|
...localInputs,
|
|
|
- id: parseInt(channelId)
|
|
|
|
|
|
|
+ id: parseInt(channelId),
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
res = await API.post(`/api/channel/`, localInputs);
|
|
res = await API.post(`/api/channel/`, localInputs);
|
|
@@ -382,7 +381,7 @@ const EditChannel = (props) => {
|
|
|
localModelOptions.push({
|
|
localModelOptions.push({
|
|
|
key: model,
|
|
key: model,
|
|
|
text: model,
|
|
text: model,
|
|
|
- value: model
|
|
|
|
|
|
|
+ value: model,
|
|
|
});
|
|
});
|
|
|
} else if (model) {
|
|
} else if (model) {
|
|
|
showError(t('某些模型已存在!'));
|
|
showError(t('某些模型已存在!'));
|
|
@@ -397,14 +396,15 @@ const EditChannel = (props) => {
|
|
|
handleInputChange('models', localModels);
|
|
handleInputChange('models', localModels);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<SideSheet
|
|
<SideSheet
|
|
|
maskClosable={false}
|
|
maskClosable={false}
|
|
|
placement={isEdit ? 'right' : 'left'}
|
|
placement={isEdit ? 'right' : 'left'}
|
|
|
title={
|
|
title={
|
|
|
- <Title level={3}>{isEdit ? t('更新渠道信息') : t('创建新的渠道')}</Title>
|
|
|
|
|
|
|
+ <Title level={3}>
|
|
|
|
|
+ {isEdit ? t('更新渠道信息') : t('创建新的渠道')}
|
|
|
|
|
+ </Title>
|
|
|
}
|
|
}
|
|
|
headerStyle={{ borderBottom: '1px solid var(--semi-color-border)' }}
|
|
headerStyle={{ borderBottom: '1px solid var(--semi-color-border)' }}
|
|
|
bodyStyle={{ borderBottom: '1px solid var(--semi-color-border)' }}
|
|
bodyStyle={{ borderBottom: '1px solid var(--semi-color-border)' }}
|
|
@@ -412,11 +412,11 @@ const EditChannel = (props) => {
|
|
|
footer={
|
|
footer={
|
|
|
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
|
<Space>
|
|
<Space>
|
|
|
- <Button theme="solid" size={'large'} onClick={submit}>
|
|
|
|
|
|
|
+ <Button theme='solid' size={'large'} onClick={submit}>
|
|
|
{t('提交')}
|
|
{t('提交')}
|
|
|
</Button>
|
|
</Button>
|
|
|
<Button
|
|
<Button
|
|
|
- theme="solid"
|
|
|
|
|
|
|
+ theme='solid'
|
|
|
size={'large'}
|
|
size={'large'}
|
|
|
type={'tertiary'}
|
|
type={'tertiary'}
|
|
|
onClick={handleCancel}
|
|
onClick={handleCancel}
|
|
@@ -432,11 +432,10 @@ const EditChannel = (props) => {
|
|
|
>
|
|
>
|
|
|
<Spin spinning={loading}>
|
|
<Spin spinning={loading}>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
-
|
|
|
|
|
<Typography.Text strong>{t('类型')}:</Typography.Text>
|
|
<Typography.Text strong>{t('类型')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Select
|
|
<Select
|
|
|
- name="type"
|
|
|
|
|
|
|
+ name='type'
|
|
|
required
|
|
required
|
|
|
optionList={CHANNEL_OPTIONS}
|
|
optionList={CHANNEL_OPTIONS}
|
|
|
value={inputs.type}
|
|
value={inputs.type}
|
|
@@ -449,17 +448,17 @@ const EditChannel = (props) => {
|
|
|
{inputs.type === 40 && (
|
|
{inputs.type === 40 && (
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
<Banner
|
|
<Banner
|
|
|
- type="info"
|
|
|
|
|
|
|
+ type='info'
|
|
|
description={
|
|
description={
|
|
|
<div>
|
|
<div>
|
|
|
- <Typography.Text strong>
|
|
|
|
|
- {t('邀请链接')}:
|
|
|
|
|
- </Typography.Text>
|
|
|
|
|
- <Typography.Text
|
|
|
|
|
|
|
+ <Typography.Text strong>{t('邀请链接')}:</Typography.Text>
|
|
|
|
|
+ <Typography.Text
|
|
|
link
|
|
link
|
|
|
- underline
|
|
|
|
|
- style={{marginLeft: 8}}
|
|
|
|
|
- onClick={() => window.open('https://cloud.siliconflow.cn/i/hij0YNTZ')}
|
|
|
|
|
|
|
+ underline
|
|
|
|
|
+ style={{ marginLeft: 8 }}
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ window.open('https://cloud.siliconflow.cn/i/hij0YNTZ')
|
|
|
|
|
+ }
|
|
|
>
|
|
>
|
|
|
https://cloud.siliconflow.cn/i/hij0YNTZ
|
|
https://cloud.siliconflow.cn/i/hij0YNTZ
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
@@ -482,27 +481,29 @@ const EditChannel = (props) => {
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- label="AZURE_OPENAI_ENDPOINT"
|
|
|
|
|
- name="azure_base_url"
|
|
|
|
|
- placeholder={t('请输入 AZURE_OPENAI_ENDPOINT,例如:https://docs-test-001.openai.azure.com')}
|
|
|
|
|
|
|
+ label='AZURE_OPENAI_ENDPOINT'
|
|
|
|
|
+ name='azure_base_url'
|
|
|
|
|
+ placeholder={t(
|
|
|
|
|
+ '请输入 AZURE_OPENAI_ENDPOINT,例如:https://docs-test-001.openai.azure.com',
|
|
|
|
|
+ )}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('base_url', value);
|
|
handleInputChange('base_url', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.base_url}
|
|
value={inputs.base_url}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
<Typography.Text strong>{t('默认 API 版本')}:</Typography.Text>
|
|
<Typography.Text strong>{t('默认 API 版本')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
label={t('默认 API 版本')}
|
|
label={t('默认 API 版本')}
|
|
|
- name="azure_other"
|
|
|
|
|
|
|
+ name='azure_other'
|
|
|
placeholder={t('请输入默认 API 版本,例如:2024-12-01-preview')}
|
|
placeholder={t('请输入默认 API 版本,例如:2024-12-01-preview')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('other', value);
|
|
handleInputChange('other', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.other}
|
|
value={inputs.other}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -511,7 +512,9 @@ const EditChannel = (props) => {
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
<Banner
|
|
<Banner
|
|
|
type={'warning'}
|
|
type={'warning'}
|
|
|
- description={t('如果你对接的是上游One API或者New API等转发项目,请使用OpenAI类型,不要使用此类型,除非你知道你在做什么。')}
|
|
|
|
|
|
|
+ description={t(
|
|
|
|
|
+ '如果你对接的是上游One API或者New API等转发项目,请使用OpenAI类型,不要使用此类型,除非你知道你在做什么。',
|
|
|
|
|
+ )}
|
|
|
></Banner>
|
|
></Banner>
|
|
|
</div>
|
|
</div>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
@@ -520,13 +523,15 @@ const EditChannel = (props) => {
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- name="base_url"
|
|
|
|
|
- placeholder={t('请输入完整的URL,例如:https://api.openai.com/v1/chat/completions')}
|
|
|
|
|
|
|
+ name='base_url'
|
|
|
|
|
+ placeholder={t(
|
|
|
|
|
+ '请输入完整的URL,例如:https://api.openai.com/v1/chat/completions',
|
|
|
|
|
+ )}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('base_url', value);
|
|
handleInputChange('base_url', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.base_url}
|
|
value={inputs.base_url}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -535,7 +540,9 @@ const EditChannel = (props) => {
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
<Banner
|
|
<Banner
|
|
|
type={'warning'}
|
|
type={'warning'}
|
|
|
- description={t('Dify渠道只适配chatflow和agent,并且agent不支持图片!')}
|
|
|
|
|
|
|
+ description={t(
|
|
|
|
|
+ 'Dify渠道只适配chatflow和agent,并且agent不支持图片!',
|
|
|
|
|
+ )}
|
|
|
></Banner>
|
|
></Banner>
|
|
|
</div>
|
|
</div>
|
|
|
</>
|
|
</>
|
|
@@ -545,40 +552,50 @@ const EditChannel = (props) => {
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
required
|
|
required
|
|
|
- name="name"
|
|
|
|
|
|
|
+ name='name'
|
|
|
placeholder={t('请为渠道命名')}
|
|
placeholder={t('请为渠道命名')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('name', value);
|
|
handleInputChange('name', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.name}
|
|
value={inputs.name}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
- {inputs.type !== 3 && inputs.type !== 8 && inputs.type !== 22 && inputs.type !== 36 && inputs.type !== 45 && (
|
|
|
|
|
- <>
|
|
|
|
|
- <div style={{ marginTop: 10 }}>
|
|
|
|
|
- <Typography.Text strong>{t('代理站地址')}:</Typography.Text>
|
|
|
|
|
- </div>
|
|
|
|
|
- <Tooltip content={t('对于官方渠道,new-api已经内置地址,除非是第三方代理站点或者Azure的特殊接入地址,否则不需要填写')}>
|
|
|
|
|
- <Input
|
|
|
|
|
- label={t('代理站地址')}
|
|
|
|
|
- name="base_url"
|
|
|
|
|
- placeholder={t('此项可选,用于通过代理站来进行 API 调用,末尾不要带/v1和/')}
|
|
|
|
|
- onChange={(value) => {
|
|
|
|
|
- handleInputChange('base_url', value);
|
|
|
|
|
- }}
|
|
|
|
|
- value={inputs.base_url}
|
|
|
|
|
- autoComplete="new-password"
|
|
|
|
|
- />
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </>
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ {inputs.type !== 3 &&
|
|
|
|
|
+ inputs.type !== 8 &&
|
|
|
|
|
+ inputs.type !== 22 &&
|
|
|
|
|
+ inputs.type !== 36 &&
|
|
|
|
|
+ inputs.type !== 45 && (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <div style={{ marginTop: 10 }}>
|
|
|
|
|
+ <Typography.Text strong>{t('代理站地址')}:</Typography.Text>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Tooltip
|
|
|
|
|
+ content={t(
|
|
|
|
|
+ '对于官方渠道,new-api已经内置地址,除非是第三方代理站点或者Azure的特殊接入地址,否则不需要填写',
|
|
|
|
|
+ )}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Input
|
|
|
|
|
+ label={t('代理站地址')}
|
|
|
|
|
+ name='base_url'
|
|
|
|
|
+ placeholder={t(
|
|
|
|
|
+ '此项可选,用于通过代理站来进行 API 调用,末尾不要带/v1和/',
|
|
|
|
|
+ )}
|
|
|
|
|
+ onChange={(value) => {
|
|
|
|
|
+ handleInputChange('base_url', value);
|
|
|
|
|
+ }}
|
|
|
|
|
+ value={inputs.base_url}
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
|
|
+ />
|
|
|
|
|
+ </Tooltip>
|
|
|
|
|
+ </>
|
|
|
|
|
+ )}
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
<Typography.Text strong>{t('密钥')}:</Typography.Text>
|
|
<Typography.Text strong>{t('密钥')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
{batch ? (
|
|
{batch ? (
|
|
|
<TextArea
|
|
<TextArea
|
|
|
label={t('密钥')}
|
|
label={t('密钥')}
|
|
|
- name="key"
|
|
|
|
|
|
|
+ name='key'
|
|
|
required
|
|
required
|
|
|
placeholder={t('请输入密钥,一行一个')}
|
|
placeholder={t('请输入密钥,一行一个')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
@@ -586,16 +603,17 @@ const EditChannel = (props) => {
|
|
|
}}
|
|
}}
|
|
|
value={inputs.key}
|
|
value={inputs.key}
|
|
|
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
|
|
style={{ minHeight: 150, fontFamily: 'JetBrains Mono, Consolas' }}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
) : (
|
|
) : (
|
|
|
<>
|
|
<>
|
|
|
{inputs.type === 41 ? (
|
|
{inputs.type === 41 ? (
|
|
|
<TextArea
|
|
<TextArea
|
|
|
label={t('鉴权json')}
|
|
label={t('鉴权json')}
|
|
|
- name="key"
|
|
|
|
|
|
|
+ name='key'
|
|
|
required
|
|
required
|
|
|
- placeholder={'{\n' +
|
|
|
|
|
|
|
+ placeholder={
|
|
|
|
|
+ '{\n' +
|
|
|
' "type": "service_account",\n' +
|
|
' "type": "service_account",\n' +
|
|
|
' "project_id": "abc-bcd-123-456",\n' +
|
|
' "project_id": "abc-bcd-123-456",\n' +
|
|
|
' "private_key_id": "123xxxxx456",\n' +
|
|
' "private_key_id": "123xxxxx456",\n' +
|
|
@@ -607,25 +625,26 @@ const EditChannel = (props) => {
|
|
|
' "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",\n' +
|
|
' "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",\n' +
|
|
|
' "client_x509_cert_url": "https://xxxxx.gserviceaccount.com",\n' +
|
|
' "client_x509_cert_url": "https://xxxxx.gserviceaccount.com",\n' +
|
|
|
' "universe_domain": "googleapis.com"\n' +
|
|
' "universe_domain": "googleapis.com"\n' +
|
|
|
- '}'}
|
|
|
|
|
|
|
+ '}'
|
|
|
|
|
+ }
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('key', value);
|
|
handleInputChange('key', value);
|
|
|
}}
|
|
}}
|
|
|
autosize={{ minRows: 10 }}
|
|
autosize={{ minRows: 10 }}
|
|
|
value={inputs.key}
|
|
value={inputs.key}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
) : (
|
|
) : (
|
|
|
<Input
|
|
<Input
|
|
|
label={t('密钥')}
|
|
label={t('密钥')}
|
|
|
- name="key"
|
|
|
|
|
|
|
+ name='key'
|
|
|
required
|
|
required
|
|
|
placeholder={t(type2secretPrompt(inputs.type))}
|
|
placeholder={t(type2secretPrompt(inputs.type))}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('key', value);
|
|
handleInputChange('key', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.key}
|
|
value={inputs.key}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
</>
|
|
</>
|
|
@@ -636,7 +655,7 @@ const EditChannel = (props) => {
|
|
|
<Checkbox
|
|
<Checkbox
|
|
|
checked={batch}
|
|
checked={batch}
|
|
|
label={t('批量创建')}
|
|
label={t('批量创建')}
|
|
|
- name="batch"
|
|
|
|
|
|
|
+ name='batch'
|
|
|
onChange={() => setBatch(!batch)}
|
|
onChange={() => setBatch(!batch)}
|
|
|
/>
|
|
/>
|
|
|
<Typography.Text strong>{t('批量创建')}</Typography.Text>
|
|
<Typography.Text strong>{t('批量创建')}</Typography.Text>
|
|
@@ -649,13 +668,15 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>{t('私有部署地址')}:</Typography.Text>
|
|
<Typography.Text strong>{t('私有部署地址')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- name="base_url"
|
|
|
|
|
- placeholder={t('请输入私有部署地址,格式为:https://fastgpt.run/api/openapi')}
|
|
|
|
|
|
|
+ name='base_url'
|
|
|
|
|
+ placeholder={t(
|
|
|
|
|
+ '请输入私有部署地址,格式为:https://fastgpt.run/api/openapi',
|
|
|
|
|
+ )}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('base_url', value);
|
|
handleInputChange('base_url', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.base_url}
|
|
value={inputs.base_url}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -663,17 +684,21 @@ const EditChannel = (props) => {
|
|
|
<>
|
|
<>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
<Typography.Text strong>
|
|
<Typography.Text strong>
|
|
|
- {t('注意非Chat API,请务必填写正确的API地址,否则可能导致无法使用')}
|
|
|
|
|
|
|
+ {t(
|
|
|
|
|
+ '注意非Chat API,请务必填写正确的API地址,否则可能导致无法使用',
|
|
|
|
|
+ )}
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- name="base_url"
|
|
|
|
|
- placeholder={t('请输入到 /suno 前的路径,通常就是域名,例如:https://api.example.com')}
|
|
|
|
|
|
|
+ name='base_url'
|
|
|
|
|
+ placeholder={t(
|
|
|
|
|
+ '请输入到 /suno 前的路径,通常就是域名,例如:https://api.example.com',
|
|
|
|
|
+ )}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('base_url', value);
|
|
handleInputChange('base_url', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.base_url}
|
|
value={inputs.base_url}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -682,7 +707,7 @@ const EditChannel = (props) => {
|
|
|
</div>
|
|
</div>
|
|
|
<Select
|
|
<Select
|
|
|
placeholder={t('请选择可以使用该渠道的分组')}
|
|
placeholder={t('请选择可以使用该渠道的分组')}
|
|
|
- name="groups"
|
|
|
|
|
|
|
+ name='groups'
|
|
|
required
|
|
required
|
|
|
multiple
|
|
multiple
|
|
|
selection
|
|
selection
|
|
@@ -692,7 +717,7 @@ const EditChannel = (props) => {
|
|
|
handleInputChange('groups', value);
|
|
handleInputChange('groups', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.groups}
|
|
value={inputs.groups}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
optionList={groupOptions}
|
|
optionList={groupOptions}
|
|
|
/>
|
|
/>
|
|
|
{inputs.type === 18 && (
|
|
{inputs.type === 18 && (
|
|
@@ -701,7 +726,7 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>模型版本:</Typography.Text>
|
|
<Typography.Text strong>模型版本:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- name="other"
|
|
|
|
|
|
|
+ name='other'
|
|
|
placeholder={
|
|
placeholder={
|
|
|
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1'
|
|
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1'
|
|
|
}
|
|
}
|
|
@@ -709,7 +734,7 @@ const EditChannel = (props) => {
|
|
|
handleInputChange('other', value);
|
|
handleInputChange('other', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.other}
|
|
value={inputs.other}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -719,29 +744,31 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>{t('部署地区')}:</Typography.Text>
|
|
<Typography.Text strong>{t('部署地区')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<TextArea
|
|
<TextArea
|
|
|
- name="other"
|
|
|
|
|
- placeholder={t('请输入部署地区,例如:us-central1\n支持使用模型映射格式\n' +
|
|
|
|
|
- '{\n' +
|
|
|
|
|
- ' "default": "us-central1",\n' +
|
|
|
|
|
- ' "claude-3-5-sonnet-20240620": "europe-west1"\n' +
|
|
|
|
|
- '}')}
|
|
|
|
|
|
|
+ name='other'
|
|
|
|
|
+ placeholder={t(
|
|
|
|
|
+ '请输入部署地区,例如:us-central1\n支持使用模型映射格式\n' +
|
|
|
|
|
+ '{\n' +
|
|
|
|
|
+ ' "default": "us-central1",\n' +
|
|
|
|
|
+ ' "claude-3-5-sonnet-20240620": "europe-west1"\n' +
|
|
|
|
|
+ '}',
|
|
|
|
|
+ )}
|
|
|
autosize={{ minRows: 2 }}
|
|
autosize={{ minRows: 2 }}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('other', value);
|
|
handleInputChange('other', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.other}
|
|
value={inputs.other}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<Typography.Text
|
|
<Typography.Text
|
|
|
style={{
|
|
style={{
|
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
|
userSelect: 'none',
|
|
userSelect: 'none',
|
|
|
- cursor: 'pointer'
|
|
|
|
|
|
|
+ cursor: 'pointer',
|
|
|
}}
|
|
}}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange(
|
|
handleInputChange(
|
|
|
'other',
|
|
'other',
|
|
|
- JSON.stringify(REGION_EXAMPLE, null, 2)
|
|
|
|
|
|
|
+ JSON.stringify(REGION_EXAMPLE, null, 2),
|
|
|
);
|
|
);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
@@ -755,14 +782,14 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>知识库 ID:</Typography.Text>
|
|
<Typography.Text strong>知识库 ID:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- label="知识库 ID"
|
|
|
|
|
- name="other"
|
|
|
|
|
|
|
+ label='知识库 ID'
|
|
|
|
|
+ name='other'
|
|
|
placeholder={'请输入知识库 ID,例如:123456'}
|
|
placeholder={'请输入知识库 ID,例如:123456'}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('other', value);
|
|
handleInputChange('other', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.other}
|
|
value={inputs.other}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -772,7 +799,7 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>Account ID:</Typography.Text>
|
|
<Typography.Text strong>Account ID:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- name="other"
|
|
|
|
|
|
|
+ name='other'
|
|
|
placeholder={
|
|
placeholder={
|
|
|
'请输入Account ID,例如:d6b5da8hk1awo8nap34ube6gh'
|
|
'请输入Account ID,例如:d6b5da8hk1awo8nap34ube6gh'
|
|
|
}
|
|
}
|
|
@@ -780,7 +807,7 @@ const EditChannel = (props) => {
|
|
|
handleInputChange('other', value);
|
|
handleInputChange('other', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.other}
|
|
value={inputs.other}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
@@ -789,7 +816,7 @@ const EditChannel = (props) => {
|
|
|
</div>
|
|
</div>
|
|
|
<Select
|
|
<Select
|
|
|
placeholder={'请选择该渠道所支持的模型'}
|
|
placeholder={'请选择该渠道所支持的模型'}
|
|
|
- name="models"
|
|
|
|
|
|
|
+ name='models'
|
|
|
required
|
|
required
|
|
|
multiple
|
|
multiple
|
|
|
selection
|
|
selection
|
|
@@ -799,13 +826,13 @@ const EditChannel = (props) => {
|
|
|
handleInputChange('models', value);
|
|
handleInputChange('models', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.models}
|
|
value={inputs.models}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
optionList={modelOptions}
|
|
optionList={modelOptions}
|
|
|
/>
|
|
/>
|
|
|
<div style={{ lineHeight: '40px', marginBottom: '12px' }}>
|
|
<div style={{ lineHeight: '40px', marginBottom: '12px' }}>
|
|
|
<Space>
|
|
<Space>
|
|
|
<Button
|
|
<Button
|
|
|
- type="primary"
|
|
|
|
|
|
|
+ type='primary'
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange('models', basicModels);
|
|
handleInputChange('models', basicModels);
|
|
|
}}
|
|
}}
|
|
@@ -813,16 +840,20 @@ const EditChannel = (props) => {
|
|
|
{t('填入相关模型')}
|
|
{t('填入相关模型')}
|
|
|
</Button>
|
|
</Button>
|
|
|
<Button
|
|
<Button
|
|
|
- type="secondary"
|
|
|
|
|
|
|
+ type='secondary'
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange('models', fullModels);
|
|
handleInputChange('models', fullModels);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{t('填入所有模型')}
|
|
{t('填入所有模型')}
|
|
|
</Button>
|
|
</Button>
|
|
|
- <Tooltip content={t('新建渠道时,请求通过当前浏览器发出;编辑已有渠道,请求通过后端服务器发出')}>
|
|
|
|
|
|
|
+ <Tooltip
|
|
|
|
|
+ content={t(
|
|
|
|
|
+ '新建渠道时,请求通过当前浏览器发出;编辑已有渠道,请求通过后端服务器发出',
|
|
|
|
|
+ )}
|
|
|
|
|
+ >
|
|
|
<Button
|
|
<Button
|
|
|
- type="tertiary"
|
|
|
|
|
|
|
+ type='tertiary'
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
fetchUpstreamModelList('models');
|
|
fetchUpstreamModelList('models');
|
|
|
}}
|
|
}}
|
|
@@ -831,7 +862,7 @@ const EditChannel = (props) => {
|
|
|
</Button>
|
|
</Button>
|
|
|
</Tooltip>
|
|
</Tooltip>
|
|
|
<Button
|
|
<Button
|
|
|
- type="warning"
|
|
|
|
|
|
|
+ type='warning'
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange('models', []);
|
|
handleInputChange('models', []);
|
|
|
}}
|
|
}}
|
|
@@ -841,7 +872,7 @@ const EditChannel = (props) => {
|
|
|
</Space>
|
|
</Space>
|
|
|
<Input
|
|
<Input
|
|
|
addonAfter={
|
|
addonAfter={
|
|
|
- <Button type="primary" onClick={addCustomModels}>
|
|
|
|
|
|
|
+ <Button type='primary' onClick={addCustomModels}>
|
|
|
{t('填入')}
|
|
{t('填入')}
|
|
|
</Button>
|
|
</Button>
|
|
|
}
|
|
}
|
|
@@ -856,53 +887,53 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>{t('模型重定向')}:</Typography.Text>
|
|
<Typography.Text strong>{t('模型重定向')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<TextArea
|
|
<TextArea
|
|
|
- placeholder={t('此项可选,用于修改请求体中的模型名称,为一个 JSON 字符串,键为请求中模型名称,值为要替换的模型名称,例如:') + `\n${JSON.stringify(MODEL_MAPPING_EXAMPLE, null, 2)}`}
|
|
|
|
|
- name="model_mapping"
|
|
|
|
|
|
|
+ placeholder={
|
|
|
|
|
+ t(
|
|
|
|
|
+ '此项可选,用于修改请求体中的模型名称,为一个 JSON 字符串,键为请求中模型名称,值为要替换的模型名称,例如:',
|
|
|
|
|
+ ) + `\n${JSON.stringify(MODEL_MAPPING_EXAMPLE, null, 2)}`
|
|
|
|
|
+ }
|
|
|
|
|
+ name='model_mapping'
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('model_mapping', value);
|
|
handleInputChange('model_mapping', value);
|
|
|
}}
|
|
}}
|
|
|
autosize
|
|
autosize
|
|
|
value={inputs.model_mapping}
|
|
value={inputs.model_mapping}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<Typography.Text
|
|
<Typography.Text
|
|
|
style={{
|
|
style={{
|
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
|
userSelect: 'none',
|
|
userSelect: 'none',
|
|
|
- cursor: 'pointer'
|
|
|
|
|
|
|
+ cursor: 'pointer',
|
|
|
}}
|
|
}}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange(
|
|
handleInputChange(
|
|
|
'model_mapping',
|
|
'model_mapping',
|
|
|
- JSON.stringify(MODEL_MAPPING_EXAMPLE, null, 2)
|
|
|
|
|
|
|
+ JSON.stringify(MODEL_MAPPING_EXAMPLE, null, 2),
|
|
|
);
|
|
);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{t('填入模板')}
|
|
{t('填入模板')}
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
- <Typography.Text strong>
|
|
|
|
|
- {t('渠道标签')}
|
|
|
|
|
- </Typography.Text>
|
|
|
|
|
|
|
+ <Typography.Text strong>{t('渠道标签')}</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
label={t('渠道标签')}
|
|
label={t('渠道标签')}
|
|
|
- name="tag"
|
|
|
|
|
|
|
+ name='tag'
|
|
|
placeholder={t('渠道标签')}
|
|
placeholder={t('渠道标签')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('tag', value);
|
|
handleInputChange('tag', value);
|
|
|
}}
|
|
}}
|
|
|
value={inputs.tag}
|
|
value={inputs.tag}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
- <Typography.Text strong>
|
|
|
|
|
- {t('渠道优先级')}
|
|
|
|
|
- </Typography.Text>
|
|
|
|
|
|
|
+ <Typography.Text strong>{t('渠道优先级')}</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
label={t('渠道优先级')}
|
|
label={t('渠道优先级')}
|
|
|
- name="priority"
|
|
|
|
|
|
|
+ name='priority'
|
|
|
placeholder={t('渠道优先级')}
|
|
placeholder={t('渠道优先级')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
const number = parseInt(value);
|
|
const number = parseInt(value);
|
|
@@ -913,16 +944,14 @@ const EditChannel = (props) => {
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
value={inputs.priority}
|
|
value={inputs.priority}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
- <Typography.Text strong>
|
|
|
|
|
- {t('渠道权重')}
|
|
|
|
|
- </Typography.Text>
|
|
|
|
|
|
|
+ <Typography.Text strong>{t('渠道权重')}</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
label={t('渠道权重')}
|
|
label={t('渠道权重')}
|
|
|
- name="weight"
|
|
|
|
|
|
|
+ name='weight'
|
|
|
placeholder={t('渠道权重')}
|
|
placeholder={t('渠道权重')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
const number = parseInt(value);
|
|
const number = parseInt(value);
|
|
@@ -933,37 +962,43 @@ const EditChannel = (props) => {
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
value={inputs.weight}
|
|
value={inputs.weight}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<>
|
|
<>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
- <Typography.Text strong>
|
|
|
|
|
- {t('渠道额外设置')}:
|
|
|
|
|
- </Typography.Text>
|
|
|
|
|
|
|
+ <Typography.Text strong>{t('渠道额外设置')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<TextArea
|
|
<TextArea
|
|
|
- placeholder={t('此项可选,用于配置渠道特定设置,为一个 JSON 字符串,例如:') + '\n{\n "force_format": true\n}'}
|
|
|
|
|
- name="setting"
|
|
|
|
|
|
|
+ placeholder={
|
|
|
|
|
+ t(
|
|
|
|
|
+ '此项可选,用于配置渠道特定设置,为一个 JSON 字符串,例如:',
|
|
|
|
|
+ ) + '\n{\n "force_format": true\n}'
|
|
|
|
|
+ }
|
|
|
|
|
+ name='setting'
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('setting', value);
|
|
handleInputChange('setting', value);
|
|
|
}}
|
|
}}
|
|
|
autosize
|
|
autosize
|
|
|
value={inputs.setting}
|
|
value={inputs.setting}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<Space>
|
|
<Space>
|
|
|
<Typography.Text
|
|
<Typography.Text
|
|
|
style={{
|
|
style={{
|
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
|
userSelect: 'none',
|
|
userSelect: 'none',
|
|
|
- cursor: 'pointer'
|
|
|
|
|
|
|
+ cursor: 'pointer',
|
|
|
}}
|
|
}}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange(
|
|
handleInputChange(
|
|
|
'setting',
|
|
'setting',
|
|
|
- JSON.stringify({
|
|
|
|
|
- force_format: true
|
|
|
|
|
- }, null, 2)
|
|
|
|
|
|
|
+ JSON.stringify(
|
|
|
|
|
+ {
|
|
|
|
|
+ force_format: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ null,
|
|
|
|
|
+ 2,
|
|
|
|
|
+ ),
|
|
|
);
|
|
);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
@@ -973,10 +1008,12 @@ const EditChannel = (props) => {
|
|
|
style={{
|
|
style={{
|
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
|
userSelect: 'none',
|
|
userSelect: 'none',
|
|
|
- cursor: 'pointer'
|
|
|
|
|
|
|
+ cursor: 'pointer',
|
|
|
}}
|
|
}}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
- window.open('https://github.com/Calcium-Ion/new-api/blob/main/docs/channel/other_setting.md');
|
|
|
|
|
|
|
+ window.open(
|
|
|
|
|
+ 'https://github.com/Calcium-Ion/new-api/blob/main/docs/channel/other_setting.md',
|
|
|
|
|
+ );
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{t('设置说明')}
|
|
{t('设置说明')}
|
|
@@ -985,19 +1022,21 @@ const EditChannel = (props) => {
|
|
|
</>
|
|
</>
|
|
|
<>
|
|
<>
|
|
|
<div style={{ marginTop: 10 }}>
|
|
<div style={{ marginTop: 10 }}>
|
|
|
- <Typography.Text strong>
|
|
|
|
|
- {t('参数覆盖')}:
|
|
|
|
|
- </Typography.Text>
|
|
|
|
|
|
|
+ <Typography.Text strong>{t('参数覆盖')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<TextArea
|
|
<TextArea
|
|
|
- placeholder={t('此项可选,用于覆盖请求参数。不支持覆盖 stream 参数。为一个 JSON 字符串,例如:') + '\n{\n "temperature": 0\n}'}
|
|
|
|
|
- name="setting"
|
|
|
|
|
|
|
+ placeholder={
|
|
|
|
|
+ t(
|
|
|
|
|
+ '此项可选,用于覆盖请求参数。不支持覆盖 stream 参数。为一个 JSON 字符串,例如:',
|
|
|
|
|
+ ) + '\n{\n "temperature": 0\n}'
|
|
|
|
|
+ }
|
|
|
|
|
+ name='setting'
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('param_override', value);
|
|
handleInputChange('param_override', value);
|
|
|
}}
|
|
}}
|
|
|
autosize
|
|
autosize
|
|
|
value={inputs.param_override}
|
|
value={inputs.param_override}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
{inputs.type === 1 && (
|
|
{inputs.type === 1 && (
|
|
@@ -1007,7 +1046,7 @@ const EditChannel = (props) => {
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
label={t('组织,可选,不填则为默认组织')}
|
|
label={t('组织,可选,不填则为默认组织')}
|
|
|
- name="openai_organization"
|
|
|
|
|
|
|
+ name='openai_organization'
|
|
|
placeholder={t('请输入组织org-xxx')}
|
|
placeholder={t('请输入组织org-xxx')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('openai_organization', value);
|
|
handleInputChange('openai_organization', value);
|
|
@@ -1020,7 +1059,7 @@ const EditChannel = (props) => {
|
|
|
<Typography.Text strong>{t('默认测试模型')}:</Typography.Text>
|
|
<Typography.Text strong>{t('默认测试模型')}:</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<Input
|
|
<Input
|
|
|
- name="test_model"
|
|
|
|
|
|
|
+ name='test_model'
|
|
|
placeholder={t('不填则为模型列表第一个')}
|
|
placeholder={t('不填则为模型列表第一个')}
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('test_model', value);
|
|
handleInputChange('test_model', value);
|
|
@@ -1030,14 +1069,16 @@ const EditChannel = (props) => {
|
|
|
<div style={{ marginTop: 10, display: 'flex' }}>
|
|
<div style={{ marginTop: 10, display: 'flex' }}>
|
|
|
<Space>
|
|
<Space>
|
|
|
<Checkbox
|
|
<Checkbox
|
|
|
- name="auto_ban"
|
|
|
|
|
|
|
+ name='auto_ban'
|
|
|
checked={autoBan}
|
|
checked={autoBan}
|
|
|
onChange={() => {
|
|
onChange={() => {
|
|
|
setAutoBan(!autoBan);
|
|
setAutoBan(!autoBan);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
<Typography.Text strong>
|
|
<Typography.Text strong>
|
|
|
- {t('是否自动禁用(仅当自动禁用开启时有效),关闭后不会自动禁用该渠道:')}
|
|
|
|
|
|
|
+ {t(
|
|
|
|
|
+ '是否自动禁用(仅当自动禁用开启时有效),关闭后不会自动禁用该渠道:',
|
|
|
|
|
+ )}
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
|
</Space>
|
|
</Space>
|
|
|
</div>
|
|
</div>
|
|
@@ -1047,26 +1088,31 @@ const EditChannel = (props) => {
|
|
|
</Typography.Text>
|
|
</Typography.Text>
|
|
|
</div>
|
|
</div>
|
|
|
<TextArea
|
|
<TextArea
|
|
|
- placeholder={t('此项可选,用于复写返回的状态码,比如将claude渠道的400错误复写为500(用于重试),请勿滥用该功能,例如:') +
|
|
|
|
|
- '\n' + JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2)}
|
|
|
|
|
- name="status_code_mapping"
|
|
|
|
|
|
|
+ placeholder={
|
|
|
|
|
+ t(
|
|
|
|
|
+ '此项可选,用于复写返回的状态码,比如将claude渠道的400错误复写为500(用于重试),请勿滥用该功能,例如:',
|
|
|
|
|
+ ) +
|
|
|
|
|
+ '\n' +
|
|
|
|
|
+ JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2)
|
|
|
|
|
+ }
|
|
|
|
|
+ name='status_code_mapping'
|
|
|
onChange={(value) => {
|
|
onChange={(value) => {
|
|
|
handleInputChange('status_code_mapping', value);
|
|
handleInputChange('status_code_mapping', value);
|
|
|
}}
|
|
}}
|
|
|
autosize
|
|
autosize
|
|
|
value={inputs.status_code_mapping}
|
|
value={inputs.status_code_mapping}
|
|
|
- autoComplete="new-password"
|
|
|
|
|
|
|
+ autoComplete='new-password'
|
|
|
/>
|
|
/>
|
|
|
<Typography.Text
|
|
<Typography.Text
|
|
|
style={{
|
|
style={{
|
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
color: 'rgba(var(--semi-blue-5), 1)',
|
|
|
userSelect: 'none',
|
|
userSelect: 'none',
|
|
|
- cursor: 'pointer'
|
|
|
|
|
|
|
+ cursor: 'pointer',
|
|
|
}}
|
|
}}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
handleInputChange(
|
|
handleInputChange(
|
|
|
'status_code_mapping',
|
|
'status_code_mapping',
|
|
|
- JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2)
|
|
|
|
|
|
|
+ JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2),
|
|
|
);
|
|
);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|