feat: add AzureNoRemoveDotTime constant and update channel handling #1044
- Introduced a new constant `AzureNoRemoveDotTime` in `constant/azure.go` to manage model name formatting for channels created after May 10, 2025. - Updated `distributor.go` to set `channel_create_time` in the context. - Modified `adaptor.go` to conditionally remove dots from model names based on the channel creation time. - Enhanced `relay_info.go` to include `ChannelCreateTime` in the `RelayInfo` struct. - Updated English localization files to reflect changes in model name handling for new channels.
This commit is contained in:
5
constant/azure.go
Normal file
5
constant/azure.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
var AzureNoRemoveDotTime = time.Date(2025, time.May, 10, 0, 0, 0, 0, time.UTC).Unix()
|
||||||
@@ -213,6 +213,7 @@ func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, mode
|
|||||||
c.Set("channel_id", channel.Id)
|
c.Set("channel_id", channel.Id)
|
||||||
c.Set("channel_name", channel.Name)
|
c.Set("channel_name", channel.Name)
|
||||||
c.Set("channel_type", channel.Type)
|
c.Set("channel_type", channel.Type)
|
||||||
|
c.Set("channel_create_time", channel.CreatedTime)
|
||||||
c.Set("channel_setting", channel.GetSetting())
|
c.Set("channel_setting", channel.GetSetting())
|
||||||
c.Set("param_override", channel.GetParamOverride())
|
c.Set("param_override", channel.GetParamOverride())
|
||||||
if nil != channel.OpenAIOrganization && "" != *channel.OpenAIOrganization {
|
if nil != channel.OpenAIOrganization && "" != *channel.OpenAIOrganization {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/textproto"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
constant2 "one-api/constant"
|
constant2 "one-api/constant"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
@@ -25,8 +26,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"net/textproto"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -93,7 +92,10 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
|||||||
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, apiVersion)
|
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, apiVersion)
|
||||||
task := strings.TrimPrefix(requestURL, "/v1/")
|
task := strings.TrimPrefix(requestURL, "/v1/")
|
||||||
model_ := info.UpstreamModelName
|
model_ := info.UpstreamModelName
|
||||||
model_ = strings.Replace(model_, ".", "", -1)
|
// 2025年5月10日后创建的渠道不移除.
|
||||||
|
if info.ChannelCreateTime < constant2.AzureNoRemoveDotTime {
|
||||||
|
model_ = strings.Replace(model_, ".", "", -1)
|
||||||
|
}
|
||||||
// https://github.com/songquanpeng/one-api/issues/67
|
// https://github.com/songquanpeng/one-api/issues/67
|
||||||
requestURL = fmt.Sprintf("/openai/deployments/%s/%s", model_, task)
|
requestURL = fmt.Sprintf("/openai/deployments/%s/%s", model_, task)
|
||||||
if info.RelayMode == constant.RelayModeRealtime {
|
if info.RelayMode == constant.RelayModeRealtime {
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ type RelayInfo struct {
|
|||||||
UserQuota int
|
UserQuota int
|
||||||
RelayFormat string
|
RelayFormat string
|
||||||
SendResponseCount int
|
SendResponseCount int
|
||||||
|
ChannelCreateTime int64
|
||||||
ThinkingContentInfo
|
ThinkingContentInfo
|
||||||
*ClaudeConvertInfo
|
*ClaudeConvertInfo
|
||||||
*RerankerInfo
|
*RerankerInfo
|
||||||
@@ -209,14 +210,15 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
|
|||||||
OriginModelName: c.GetString("original_model"),
|
OriginModelName: c.GetString("original_model"),
|
||||||
UpstreamModelName: c.GetString("original_model"),
|
UpstreamModelName: c.GetString("original_model"),
|
||||||
//RecodeModelName: c.GetString("original_model"),
|
//RecodeModelName: c.GetString("original_model"),
|
||||||
IsModelMapped: false,
|
IsModelMapped: false,
|
||||||
ApiType: apiType,
|
ApiType: apiType,
|
||||||
ApiVersion: c.GetString("api_version"),
|
ApiVersion: c.GetString("api_version"),
|
||||||
ApiKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
|
ApiKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
|
||||||
Organization: c.GetString("channel_organization"),
|
Organization: c.GetString("channel_organization"),
|
||||||
ChannelSetting: channelSetting,
|
ChannelSetting: channelSetting,
|
||||||
ParamOverride: paramOverride,
|
ChannelCreateTime: c.GetInt64("channel_create_time"),
|
||||||
RelayFormat: RelayFormatOpenAI,
|
ParamOverride: paramOverride,
|
||||||
|
RelayFormat: RelayFormatOpenAI,
|
||||||
ThinkingContentInfo: ThinkingContentInfo{
|
ThinkingContentInfo: ThinkingContentInfo{
|
||||||
IsFirstThinkingContent: true,
|
IsFirstThinkingContent: true,
|
||||||
SendLastThinkingContent: false,
|
SendLastThinkingContent: false,
|
||||||
|
|||||||
@@ -493,6 +493,7 @@
|
|||||||
"默认": "default",
|
"默认": "default",
|
||||||
"图片演示": "Image demo",
|
"图片演示": "Image demo",
|
||||||
"注意,系统请求的时模型名称中的点会被剔除,例如:gpt-4.1会请求为gpt-41,所以在Azure部署的时候,部署模型名称需要手动改为gpt-41": "Note that the dot in the model name requested by the system will be removed, for example: gpt-4.1 will be requested as gpt-41, so when deploying on Azure, the deployment model name needs to be manually changed to gpt-41",
|
"注意,系统请求的时模型名称中的点会被剔除,例如:gpt-4.1会请求为gpt-41,所以在Azure部署的时候,部署模型名称需要手动改为gpt-41": "Note that the dot in the model name requested by the system will be removed, for example: gpt-4.1 will be requested as gpt-41, so when deploying on Azure, the deployment model name needs to be manually changed to gpt-41",
|
||||||
|
"2025年5月10日后添加的渠道,不需要再在部署的时候移除模型名称中的\".\"": "After May 10, 2025, channels added do not need to remove the dot in the model name during deployment",
|
||||||
"模型映射必须是合法的 JSON 格式!": "Model mapping must be in valid JSON format!",
|
"模型映射必须是合法的 JSON 格式!": "Model mapping must be in valid JSON format!",
|
||||||
"取消无限额度": "Cancel unlimited quota",
|
"取消无限额度": "Cancel unlimited quota",
|
||||||
"取消": "Cancel",
|
"取消": "Cancel",
|
||||||
|
|||||||
@@ -477,24 +477,24 @@ const EditChannel = (props) => {
|
|||||||
type={'warning'}
|
type={'warning'}
|
||||||
description={
|
description={
|
||||||
<>
|
<>
|
||||||
{t('注意,系统请求的时模型名称中的点会被剔除,例如:gpt-4.1会请求为gpt-41,所以在Azure部署的时候,部署模型名称需要手动改为gpt-41')}
|
{t('2025年5月10日后添加的渠道,不需要再在部署的时候移除模型名称中的"."')}
|
||||||
<br />
|
{/*<br />*/}
|
||||||
<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',*/}
|
||||||
}}
|
{/* }}*/}
|
||||||
onClick={() => {
|
{/* onClick={() => {*/}
|
||||||
setModalImageUrl(
|
{/* setModalImageUrl(*/}
|
||||||
'/azure_model_name.png',
|
{/* '/azure_model_name.png',*/}
|
||||||
);
|
{/* );*/}
|
||||||
setIsModalOpenurl(true)
|
{/* setIsModalOpenurl(true)*/}
|
||||||
|
|
||||||
}}
|
{/* }}*/}
|
||||||
>
|
{/*>*/}
|
||||||
{t('查看示例')}
|
{/* {t('查看示例')}*/}
|
||||||
</Typography.Text>
|
{/*</Typography.Text>*/}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
></Banner>
|
></Banner>
|
||||||
|
|||||||
Reference in New Issue
Block a user