feat(channel model list): modify fetching model list in add channel to fetch by type

This commit is contained in:
mango
2025-01-07 12:40:36 +08:00
parent fc33f2f0a5
commit f5be2868df
2 changed files with 6 additions and 4 deletions

View File

@@ -510,6 +510,7 @@ func UpdateChannel(c *gin.Context) {
func FetchModels(c *gin.Context) { func FetchModels(c *gin.Context) {
var req struct { var req struct {
BaseURL string `json:"base_url"` BaseURL string `json:"base_url"`
Type int `json:"type"`
Key string `json:"key"` Key string `json:"key"`
} }
@@ -523,7 +524,7 @@ func FetchModels(c *gin.Context) {
baseURL := req.BaseURL baseURL := req.BaseURL
if baseURL == "" { if baseURL == "" {
baseURL = "https://api.openai.com" baseURL = common.ChannelBaseURLs[req.Type]
} }
client := &http.Client{} client := &http.Client{}

View File

@@ -218,6 +218,7 @@ const EditChannel = (props) => {
try { try {
const res = await API.post('/api/channel/fetch_models', { const res = await API.post('/api/channel/fetch_models', {
base_url: inputs['base_url'], base_url: inputs['base_url'],
type: inputs['type'],
key: inputs['key'] key: inputs['key']
}); });
@@ -885,7 +886,7 @@ const EditChannel = (props) => {
</Typography.Text> </Typography.Text>
</div> </div>
<TextArea <TextArea
placeholder={t('此项可选用于复写返回的状态码比如将claude渠道的400错误复写为500用于重试请勿滥用该功能例如') + placeholder={t('此项可选用于复写返回的状态码比如将claude渠道的400错误复写为500用于重试请勿滥用该功能例如') +
'\n' + JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2)} '\n' + JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2)}
name="status_code_mapping" name="status_code_mapping"
onChange={(value) => { onChange={(value) => {
@@ -984,7 +985,7 @@ const EditChannel = (props) => {
/> />
<Typography.Text <Typography.Text
style={{ style={{
color: 'rgba(var(--semi-blue-5), 1)', color: 'rgba(var(--semi-blue-5), 1)',
userSelect: 'none', userSelect: 'none',
cursor: 'pointer' cursor: 'pointer'
}} }}
@@ -1000,7 +1001,7 @@ const EditChannel = (props) => {
{t('填入模板')} {t('填入模板')}
</Typography.Text> </Typography.Text>
</> </>
)} )}
</Spin> </Spin>
</SideSheet> </SideSheet>
</> </>