diff --git a/web/berry/src/constants/ChannelConstants.js b/web/berry/src/constants/ChannelConstants.js
index e6b0aed5..589ef1fb 100644
--- a/web/berry/src/constants/ChannelConstants.js
+++ b/web/berry/src/constants/ChannelConstants.js
@@ -11,12 +11,18 @@ export const CHANNEL_OPTIONS = {
value: 14,
color: 'primary'
},
- // 33: {
- // key: 33,
- // text: 'AWS Claude',
- // value: 33,
- // color: 'primary'
- // },
+ 33: {
+ key: 33,
+ text: 'AWS Claude',
+ value: 33,
+ color: 'primary'
+ },
+ 37: {
+ key: 37,
+ text: 'Cloudflare',
+ value: 37,
+ color: 'success'
+ },
3: {
key: 3,
text: 'Azure OpenAI',
@@ -119,12 +125,12 @@ export const CHANNEL_OPTIONS = {
value: 32,
color: 'primary'
},
- // 34: {
- // key: 34,
- // text: 'Coze',
- // value: 34,
- // color: 'primary'
- // },
+ 34: {
+ key: 34,
+ text: 'Coze',
+ value: 34,
+ color: 'primary'
+ },
35: {
key: 35,
text: 'Cohere',
diff --git a/web/berry/src/views/Channel/component/EditModal.js b/web/berry/src/views/Channel/component/EditModal.js
index fc568d35..4f7f216d 100644
--- a/web/berry/src/views/Channel/component/EditModal.js
+++ b/web/berry/src/views/Channel/component/EditModal.js
@@ -40,8 +40,8 @@ const validationSchema = Yup.object().shape({
is_edit: Yup.boolean(),
name: Yup.string().required('名称 不能为空'),
type: Yup.number().required('渠道 不能为空'),
- key: Yup.string().when('is_edit', {
- is: false,
+ key: Yup.string().when(['is_edit', 'type'], {
+ is: (is_edit, type) => !is_edit && type !== 33,
then: Yup.string().required('密钥 不能为空')
}),
other: Yup.string(),
@@ -107,6 +107,8 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
if (localModels.length > 0 && Array.isArray(values['models']) && values['models'].length == 0) {
setFieldValue('models', initialModel(localModels));
}
+
+ setFieldValue('config', {});
};
const fetchGroups = async () => {
@@ -160,17 +162,25 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
if (values.type === 18 && values.other === '') {
values.other = 'v2.1';
}
+ if (values.key === '') {
+ if (values.config.ak !== '' && values.config.sk !== '' && values.config.region !== '') {
+ values.key = `${values.config.ak}|${values.config.sk}|${values.config.region}`;
+ }
+ }
+
let res;
const modelsStr = values.models.map((model) => model.id).join(',');
+ const configStr = JSON.stringify(values.config);
values.group = values.groups.join(',');
if (channelId) {
res = await API.put(`/api/channel/`, {
...values,
id: parseInt(channelId),
- models: modelsStr
+ models: modelsStr,
+ config: configStr
});
} else {
- res = await API.post(`/api/channel/`, { ...values, models: modelsStr });
+ res = await API.post(`/api/channel/`, { ...values, models: modelsStr, config: configStr });
}
const { success, message } = res.data;
if (success) {
@@ -225,6 +235,10 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
if (data.model_mapping !== '') {
data.model_mapping = JSON.stringify(JSON.parse(data.model_mapping), null, 2);
}
+ if (data.config !== '') {
+ data.config = JSON.parse(data.config);
+ }
+
data.base_url = data.base_url ?? '';
data.is_edit = true;
initChannel(data.type);
@@ -485,55 +499,78 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
-
- {!batchAdd ? (
- <>
- {inputLabel.key}
-
- >
- ) : (
-
- )}
+ {inputLabel.key && (
+ <>
+
+ {!batchAdd ? (
+ <>
+ {inputLabel.key}
+
+ >
+ ) : (
+
+ )}
- {touched.key && errors.key ? (
-
- {errors.key}
-
- ) : (
- {inputPrompt.key}
- )}
-
- {channelId === 0 && (
-
- setBatchAdd(e.target.checked)} />
- 批量添加
-
+ {touched.key && errors.key ? (
+
+ {errors.key}
+
+ ) : (
+ {inputPrompt.key}
+ )}
+
+ {channelId === 0 && (
+
+ setBatchAdd(e.target.checked)} />
+ 批量添加
+
+ )}
+ >
)}
+
+ {inputLabel.config &&
+ Object.keys(inputLabel.config).map((configName) => {
+ return (
+
+
+ {inputPrompt.config[configName]}
+
+ );
+ })}
+
{/* {inputLabel.model_mapping} */}