merge upstream

Signed-off-by: wozulong <>
This commit is contained in:
wozulong 2024-05-22 11:38:59 +08:00
commit daa1741aed
7 changed files with 131 additions and 119 deletions

View File

@ -41,10 +41,10 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
return relaycommon.GetFullRequestURL(info.BaseUrl, requestURL, info.ChannelType), nil return relaycommon.GetFullRequestURL(info.BaseUrl, requestURL, info.ChannelType), nil
case common.ChannelTypeMiniMax: case common.ChannelTypeMiniMax:
return minimax.GetRequestURL(info) return minimax.GetRequestURL(info)
//case common.ChannelTypeCustom: case common.ChannelTypeCustom:
// url := info.BaseUrl url := info.BaseUrl
// url = strings.Replace(url, "{model}", info.UpstreamModelName, -1) url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
// return url, nil return url, nil
default: default:
return relaycommon.GetFullRequestURL(info.BaseUrl, info.RequestURLPath, info.ChannelType), nil return relaycommon.GetFullRequestURL(info.BaseUrl, info.RequestURLPath, info.ChannelType), nil
} }

View File

@ -310,12 +310,12 @@ const ChannelsTable = () => {
const setChannelFormat = (channels) => { const setChannelFormat = (channels) => {
for (let i = 0; i < channels.length; i++) { for (let i = 0; i < channels.length; i++) {
if (channels[i].type === 8) { // if (channels[i].type === 8) {
showWarning( // showWarning(
'检测到您使用了“自定义渠道”类型请更换为“OpenAI”渠道类型', // '检测到您使用了“自定义渠道”类型请更换为“OpenAI”渠道类型',
); // );
showWarning('下个版本将不再支持“自定义渠道”类型!'); // showWarning('下个版本将不再支持“自定义渠道”类型!');
} // }
channels[i].key = '' + channels[i].id; channels[i].key = '' + channels[i].id;
let test_models = []; let test_models = [];
channels[i].models.split(',').forEach((item, index) => { channels[i].models.split(',').forEach((item, index) => {

View File

@ -302,6 +302,9 @@ const LogsTable = () => {
let content = '渠道:' + record.channel; let content = '渠道:' + record.channel;
if (record.other !== '') { if (record.other !== '') {
let other = JSON.parse(record.other); let other = JSON.parse(record.other);
if (other === null) {
return <></>;
}
if (other.admin_info !== undefined) { if (other.admin_info !== undefined) {
if ( if (
other.admin_info.use_channel !== null && other.admin_info.use_channel !== null &&
@ -323,6 +326,10 @@ const LogsTable = () => {
dataIndex: 'content', dataIndex: 'content',
render: (text, record, index) => { render: (text, record, index) => {
if (record.other === '') { if (record.other === '') {
record.other = '{}';
}
let other = JSON.parse(record.other);
if (other == null) {
return ( return (
<Paragraph <Paragraph
ellipsis={{ ellipsis={{
@ -338,7 +345,6 @@ const LogsTable = () => {
</Paragraph> </Paragraph>
); );
} }
let other = JSON.parse(record.other);
let content = renderModelPrice( let content = renderModelPrice(
record.prompt_tokens, record.prompt_tokens,
record.completion_tokens, record.completion_tokens,

View File

@ -146,11 +146,12 @@ const ModelPricing = () => {
render: (text, record, index) => { render: (text, record, index) => {
let content = text; let content = text;
if (record.quota_type === 0) { if (record.quota_type === 0) {
let inputRatioPrice = record.model_ratio * 2.0 * record.group_ratio; // 这里的 *2 是因为 1倍率=0.002刀,请勿删除
let inputRatioPrice = record.model_ratio * 2 * record.group_ratio;
let completionRatioPrice = let completionRatioPrice =
record.model_ratio * record.model_ratio *
record.completion_ratio * record.completion_ratio *
2.0 * 2 *
record.group_ratio; record.group_ratio;
content = ( content = (
<> <>

View File

@ -149,8 +149,9 @@ export function renderModelPrice(
if (completionRatio === undefined) { if (completionRatio === undefined) {
completionRatio = 0; completionRatio = 0;
} }
// 这里的 *2 是因为 1倍率=0.002刀,请勿删除
let inputRatioPrice = modelRatio * 2.0 * groupRatio; let inputRatioPrice = modelRatio * 2.0 * groupRatio;
let completionRatioPrice = modelRatio * completionRatio * 2.0 * groupRatio; let completionRatioPrice = modelRatio * 2.0 * completionRatio * groupRatio;
let price = let price =
(inputTokens / 1000000) * inputRatioPrice + (inputTokens / 1000000) * inputRatioPrice +
(completionTokens / 1000000) * completionRatioPrice; (completionTokens / 1000000) * completionRatioPrice;

View File

@ -433,11 +433,15 @@ const EditChannel = (props) => {
{inputs.type === 8 && ( {inputs.type === 8 && (
<> <>
<div style={{ marginTop: 10 }}> <div style={{ marginTop: 10 }}>
<Typography.Text strong>Base URL</Typography.Text> <Typography.Text strong>
完整的 Base URL支持变量{'{model}'}
</Typography.Text>
</div> </div>
<Input <Input
name='base_url' name='base_url'
placeholder={'请输入自定义渠道的 Base URL'} placeholder={
'请输入完整的URL例如https://api.openai.com/v1/chat/completions'
}
onChange={(value) => { onChange={(value) => {
handleInputChange('base_url', value); handleInputChange('base_url', value);
}} }}