mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-30 22:11:46 +00:00
refactor: rename AWS model ID and region prefix functions for clarity
This commit is contained in:
@@ -88,7 +88,7 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
|
|||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
if info.ChannelOtherSettings.AwsKeyType == dto.AwsKeyTypeApiKey {
|
if info.ChannelOtherSettings.AwsKeyType == dto.AwsKeyTypeApiKey {
|
||||||
awsModelId := awsModelID(info.UpstreamModelName)
|
awsModelId := getAwsModelID(info.UpstreamModelName)
|
||||||
a.ClientMode = ClientModeApiKey
|
a.ClientMode = ClientModeApiKey
|
||||||
awsSecret := strings.Split(info.ApiKey, "|")
|
awsSecret := strings.Split(info.ApiKey, "|")
|
||||||
if len(awsSecret) != 2 {
|
if len(awsSecret) != 2 {
|
||||||
|
|||||||
@@ -57,9 +57,11 @@ func doAwsClientRequest(c *gin.Context, info *relaycommon.RelayInfo, a *Adaptor,
|
|||||||
}
|
}
|
||||||
a.AwsClient = awsCli
|
a.AwsClient = awsCli
|
||||||
|
|
||||||
awsModelId := awsModelID(info.UpstreamModelName)
|
println(info.UpstreamModelName)
|
||||||
|
// 获取对应的AWS模型ID
|
||||||
|
awsModelId := getAwsModelID(info.UpstreamModelName)
|
||||||
|
|
||||||
awsRegionPrefix := awsRegionPrefix(awsCli.Options().Region)
|
awsRegionPrefix := getAwsRegionPrefix(awsCli.Options().Region)
|
||||||
canCrossRegion := awsModelCanCrossRegion(awsModelId, awsRegionPrefix)
|
canCrossRegion := awsModelCanCrossRegion(awsModelId, awsRegionPrefix)
|
||||||
if canCrossRegion {
|
if canCrossRegion {
|
||||||
awsModelId = awsModelCrossRegion(awsModelId, awsRegionPrefix)
|
awsModelId = awsModelCrossRegion(awsModelId, awsRegionPrefix)
|
||||||
@@ -119,7 +121,7 @@ func doAwsClientRequest(c *gin.Context, info *relaycommon.RelayInfo, a *Adaptor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func awsRegionPrefix(awsRegionId string) string {
|
func getAwsRegionPrefix(awsRegionId string) string {
|
||||||
parts := strings.Split(awsRegionId, "-")
|
parts := strings.Split(awsRegionId, "-")
|
||||||
regionPrefix := ""
|
regionPrefix := ""
|
||||||
if len(parts) > 0 {
|
if len(parts) > 0 {
|
||||||
@@ -141,11 +143,10 @@ func awsModelCrossRegion(awsModelId, awsRegionPrefix string) string {
|
|||||||
return modelPrefix + "." + awsModelId
|
return modelPrefix + "." + awsModelId
|
||||||
}
|
}
|
||||||
|
|
||||||
func awsModelID(requestModel string) string {
|
func getAwsModelID(requestModel string) string {
|
||||||
if awsModelID, ok := awsModelIDMap[requestModel]; ok {
|
if awsModelIDName, ok := awsModelIDMap[requestModel]; ok {
|
||||||
return awsModelID
|
return awsModelIDName
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestModel
|
return requestModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user