mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-21 11:37:21 +00:00
Support custom channel now
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
export const CHANNEL_OPTIONS = [
|
||||
{ key: 1, text: 'OpenAI', value: 1, color: 'green' },
|
||||
{ key: 2, text: 'API2D', value: 2, color: 'blue' },
|
||||
{ key: 3, text: 'Azure', value: 3, color: 'olive' },
|
||||
{ key: 4, text: 'CloseAI', value: 4, color: 'teal' },
|
||||
{ key: 5, text: 'OpenAI-SB', value: 5, color: 'brown' },
|
||||
{ key: 6, text: 'OpenAI Max', value: 6, color: 'violet' },
|
||||
{ key: 7, text: 'OhMyGPT', value: 7, color: 'purple' }
|
||||
{ key: 1, text: 'OpenAI', value: 1, color: 'green' },
|
||||
{ key: 2, text: 'API2D', value: 2, color: 'blue' },
|
||||
{ key: 3, text: 'Azure', value: 3, color: 'olive' },
|
||||
{ key: 4, text: 'CloseAI', value: 4, color: 'teal' },
|
||||
{ key: 5, text: 'OpenAI-SB', value: 5, color: 'brown' },
|
||||
{ key: 6, text: 'OpenAI Max', value: 6, color: 'violet' },
|
||||
{ key: 7, text: 'OhMyGPT', value: 7, color: 'purple' },
|
||||
{ key: 8, text: '自定义', value: 8, color: 'pink' }
|
||||
];
|
||||
|
@@ -7,7 +7,8 @@ const AddChannel = () => {
|
||||
const originInputs = {
|
||||
name: '',
|
||||
type: 1,
|
||||
key: ''
|
||||
key: '',
|
||||
base_url: '',
|
||||
};
|
||||
const [inputs, setInputs] = useState(originInputs);
|
||||
const { name, type, key } = inputs;
|
||||
@@ -18,6 +19,9 @@ const AddChannel = () => {
|
||||
|
||||
const submit = async () => {
|
||||
if (inputs.name === '' || inputs.key === '') return;
|
||||
if (inputs.base_url.endsWith('/')) {
|
||||
inputs.base_url = inputs.base_url.slice(0, inputs.base_url.length - 1);
|
||||
}
|
||||
const res = await API.post(`/api/channel/`, inputs);
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
@@ -42,6 +46,20 @@ const AddChannel = () => {
|
||||
onChange={handleInputChange}
|
||||
/>
|
||||
</Form.Field>
|
||||
{
|
||||
type === 8 && (
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='Base URL'
|
||||
name='base_url'
|
||||
placeholder={'请输入自定义渠道的 Base URL'}
|
||||
onChange={handleInputChange}
|
||||
value={inputs.base_url}
|
||||
autoComplete='off'
|
||||
/>
|
||||
</Form.Field>
|
||||
)
|
||||
}
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='名称'
|
||||
|
@@ -12,6 +12,7 @@ const EditChannel = () => {
|
||||
name: '',
|
||||
key: '',
|
||||
type: 1,
|
||||
base_url: '',
|
||||
});
|
||||
const handleInputChange = (e, { name, value }) => {
|
||||
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
||||
@@ -33,6 +34,9 @@ const EditChannel = () => {
|
||||
}, []);
|
||||
|
||||
const submit = async () => {
|
||||
if (inputs.base_url.endsWith('/')) {
|
||||
inputs.base_url = inputs.base_url.slice(0, inputs.base_url.length - 1);
|
||||
}
|
||||
let res = await API.put(`/api/channel/`, { ...inputs, id: parseInt(channelId) });
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
@@ -56,6 +60,20 @@ const EditChannel = () => {
|
||||
onChange={handleInputChange}
|
||||
/>
|
||||
</Form.Field>
|
||||
{
|
||||
inputs.type === 8 && (
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='Base URL'
|
||||
name='base_url'
|
||||
placeholder={'请输入新的自定义渠道的 Base URL'}
|
||||
onChange={handleInputChange}
|
||||
value={inputs.base_url}
|
||||
autoComplete='off'
|
||||
/>
|
||||
</Form.Field>
|
||||
)
|
||||
}
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='名称'
|
||||
|
Reference in New Issue
Block a user