This commit is contained in:
wood 2023-11-05 20:49:28 +08:00
parent c51417d4e6
commit 436ba6df72
3 changed files with 21 additions and 24 deletions

View File

@ -13,8 +13,6 @@ import (
"strings"
"sync"
"time"
"strings"
"github.com/gin-gonic/gin"
)
func testChannel(channel *model.Channel, request ChatRequest) (err error, openaiErr *OpenAIError) {
@ -49,11 +47,8 @@ func testChannel(channel *model.Channel, request ChatRequest) (err error, openai
} else {
if channel.GetBaseURL() != "" {
requestURL = channel.GetBaseURL()
if !strings.HasPrefix(requestURL, "https://gateway.ai.cloudflare.com") {
requestURL += "/v1"
}
}
requestURL += "/chat/completions"
requestURL += "/v1/chat/completions"
}
// for Cloudflare AI gateway: https://github.com/songquanpeng/one-api/pull/639
requestURL = strings.Replace(requestURL, "/v1/v1", "/v1", 1)
@ -233,4 +228,4 @@ func AutomaticallyTestChannels(frequency int) {
_ = testAllChannels(false)
common.SysLog("channel test finished")
}
}
}

View File

@ -449,16 +449,6 @@ const ChannelsTable = () => {
>
测试
</Button>
{/*<Button*/}
{/* size={'small'}*/}
{/* positive*/}
{/* loading={updatingBalance}*/}
{/* onClick={() => {*/}
{/* updateChannelBalance(channel.id, channel.name, idx);*/}
{/* }}*/}
{/*>*/}
{/* 更新余额*/}
{/*</Button>*/}
<Popup
trigger={
<Button size='small' negative>

View File

@ -52,7 +52,8 @@ const EditChannel = () => {
const [modelOptions, setModelOptions] = useState([]);
const [groupOptions, setGroupOptions] = useState([]);
const [basicModels, setBasicModels] = useState([]);
const [fullModels, setFullModels] = useState([]);
const [basicNoGPTModels, setBasicNoGPTModels] = useState([]);
const [fullOPENAIModels, setFullOPENAIModels] = useState([]);
const [customModel, setCustomModel] = useState('');
const handleInputChange = (e, { name, value }) => {
setInputs((inputs) => ({ ...inputs, [name]: value }));
@ -121,10 +122,18 @@ const EditChannel = () => {
value: model.id
}));
setOriginModelOptions(localModelOptions);
setFullModels(res.data.data.map((model) => model.id));
setBasicModels(res.data.data.filter((model) => {
return model.id.startsWith('gpt-3') || model.id.startsWith('text-') || model.id.startsWith('dall-') || model.id.startsWith('whisper-');
setFullOPENAIModels(res.data.data.filter((model) => {
return (model.id.startsWith('gpt-') || model.id.startsWith('text-') || model.id.startsWith('dall-') || model.id.startsWith('whisper-') || model.id.startsWith('code-')) && !model.id.startsWith('text-embedding-v1');
}).map((model) => model.id));
setBasicModels(res.data.data.filter((model) => {
return (model.id.startsWith('gpt-3') || model.id.startsWith('text-') || model.id.startsWith('dall-') || model.id.startsWith('whisper-') || model.id.startsWith('code-')) && !model.id.startsWith('text-embedding-v1');
}).map((model) => model.id));
setBasicNoGPTModels(res.data.data.filter((model) => {
return (model.id.startsWith('text-') || model.id.startsWith('dall-') || model.id.startsWith('whisper-') || model.id.startsWith('code-')) && !model.id.startsWith('text-embedding-v1');
}).map((model) => model.id));
} catch (error) {
showError(error.message);
}
@ -361,10 +370,13 @@ const EditChannel = () => {
<div style={{ lineHeight: '40px', marginBottom: '12px' }}>
<Button type={'button'} onClick={() => {
handleInputChange(null, { name: 'models', value: basicModels });
}}>填入基础模型</Button>
}}>填入基础OPENAI模型</Button>
<Button type={'button'} onClick={() => {
handleInputChange(null, { name: 'models', value: fullModels });
}}>填入所有模型</Button>
handleInputChange(null, { name: 'models', value: basicNoGPTModels });
}}>填入基础无gpt模型</Button>
<Button type={'button'} onClick={() => {
handleInputChange(null, { name: 'models', value: fullOPENAIModels });
}}>填入所有OPENAI模型</Button>
<Button type={'button'} onClick={() => {
handleInputChange(null, { name: 'models', value: [] });
}}>清除所有模型</Button>