mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-14 20:23:46 +08:00
✨ add channel proxy
This commit is contained in:
@@ -35,6 +35,7 @@ const validationSchema = Yup.object().shape({
|
||||
type: Yup.number().required('渠道 不能为空'),
|
||||
key: Yup.string().when('is_edit', { is: false, then: Yup.string().required('密钥 不能为空') }),
|
||||
other: Yup.string(),
|
||||
proxy: Yup.string(),
|
||||
models: Yup.array().min(1, '模型 不能为空'),
|
||||
groups: Yup.array().min(1, '用户组 不能为空'),
|
||||
base_url: Yup.string().when('type', {
|
||||
@@ -442,6 +443,27 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
|
||||
<FormHelperText id="helper-tex-channel-model_mapping-label"> {inputPrompt.model_mapping} </FormHelperText>
|
||||
)}
|
||||
</FormControl>
|
||||
<FormControl fullWidth error={Boolean(touched.proxy && errors.proxy)} sx={{ ...theme.typography.otherInput }}>
|
||||
<InputLabel htmlFor="channel-proxy-label">{inputLabel.proxy}</InputLabel>
|
||||
<OutlinedInput
|
||||
id="channel-proxy-label"
|
||||
label={inputLabel.proxy}
|
||||
type="text"
|
||||
value={values.proxy}
|
||||
name="proxy"
|
||||
onBlur={handleBlur}
|
||||
onChange={handleChange}
|
||||
inputProps={{}}
|
||||
aria-describedby="helper-text-channel-proxy-label"
|
||||
/>
|
||||
{touched.proxy && errors.proxy ? (
|
||||
<FormHelperText error id="helper-tex-channel-proxy-label">
|
||||
{errors.proxy}
|
||||
</FormHelperText>
|
||||
) : (
|
||||
<FormHelperText id="helper-tex-channel-proxy-label"> {inputPrompt.proxy} </FormHelperText>
|
||||
)}
|
||||
</FormControl>
|
||||
<DialogActions>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button disableElevation disabled={isSubmitting} type="submit" variant="contained" color="primary">
|
||||
|
||||
53
web/src/views/Channel/component/NameLabel.js
Normal file
53
web/src/views/Channel/component/NameLabel.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Tooltip, Stack, Container } from '@mui/material';
|
||||
import Label from 'ui-component/Label';
|
||||
import { styled } from '@mui/material/styles';
|
||||
import { showSuccess } from 'utils/common';
|
||||
|
||||
const TooltipContainer = styled(Container)({
|
||||
maxHeight: '250px',
|
||||
overflow: 'auto',
|
||||
'&::-webkit-scrollbar': {
|
||||
width: '0px' // Set the width to 0 to hide the scrollbar
|
||||
}
|
||||
});
|
||||
|
||||
const NameLabel = ({ name, models }) => {
|
||||
let modelMap = [];
|
||||
modelMap = models.split(',');
|
||||
modelMap.sort();
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
title={
|
||||
<TooltipContainer>
|
||||
<Stack spacing={1}>
|
||||
{modelMap.map((item, index) => {
|
||||
return (
|
||||
<Label
|
||||
variant="ghost"
|
||||
key={index}
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(item);
|
||||
showSuccess('复制模型名称成功!');
|
||||
}}
|
||||
>
|
||||
{item}
|
||||
</Label>
|
||||
);
|
||||
})}
|
||||
</Stack>
|
||||
</TooltipContainer>
|
||||
}
|
||||
placement="top"
|
||||
>
|
||||
{name}
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
NameLabel.propTypes = {
|
||||
group: PropTypes.string
|
||||
};
|
||||
|
||||
export default NameLabel;
|
||||
@@ -29,6 +29,7 @@ import TableSwitch from 'ui-component/Switch';
|
||||
|
||||
import ResponseTimeLabel from './ResponseTimeLabel';
|
||||
import GroupLabel from './GroupLabel';
|
||||
import NameLabel from './NameLabel';
|
||||
|
||||
import { IconDotsVertical, IconEdit, IconTrash, IconPencil } from '@tabler/icons-react';
|
||||
|
||||
@@ -102,7 +103,9 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
|
||||
<TableRow tabIndex={item.id}>
|
||||
<TableCell>{item.id}</TableCell>
|
||||
|
||||
<TableCell>{item.name}</TableCell>
|
||||
<TableCell>
|
||||
<NameLabel name={item.name} models={item.models} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<GroupLabel group={item.group} />
|
||||
|
||||
@@ -5,6 +5,7 @@ const defaultConfig = {
|
||||
key: '',
|
||||
base_url: '',
|
||||
other: '',
|
||||
proxy: '',
|
||||
model_mapping: '',
|
||||
models: [],
|
||||
groups: ['default']
|
||||
@@ -15,6 +16,7 @@ const defaultConfig = {
|
||||
base_url: '渠道API地址',
|
||||
key: '密钥',
|
||||
other: '其他参数',
|
||||
proxy: '代理地址',
|
||||
models: '模型',
|
||||
model_mapping: '模型映射关系',
|
||||
groups: '用户组'
|
||||
@@ -25,6 +27,7 @@ const defaultConfig = {
|
||||
base_url: '可空,请输入中转API地址,例如通过cloudflare中转',
|
||||
key: '请输入渠道对应的鉴权密钥',
|
||||
other: '',
|
||||
proxy: '单独设置代理地址,支持http和socks5,例如:http://127.0.0.1:1080',
|
||||
models: '请选择该渠道所支持的模型',
|
||||
model_mapping:
|
||||
'请输入要修改的模型映射关系,格式为:api请求模型ID:实际转发给渠道的模型ID,使用JSON数组表示,例如:{"gpt-3.5": "gpt-35"}',
|
||||
|
||||
Reference in New Issue
Block a user