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" "strings"
"sync" "sync"
"time" "time"
"strings"
"github.com/gin-gonic/gin"
) )
func testChannel(channel *model.Channel, request ChatRequest) (err error, openaiErr *OpenAIError) { 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 { } else {
if channel.GetBaseURL() != "" { if channel.GetBaseURL() != "" {
requestURL = 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 // for Cloudflare AI gateway: https://github.com/songquanpeng/one-api/pull/639
requestURL = strings.Replace(requestURL, "/v1/v1", "/v1", 1) requestURL = strings.Replace(requestURL, "/v1/v1", "/v1", 1)

View File

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

View File

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