@@ -24,11 +24,8 @@ import (
2424)
2525
2626const (
27- contextKeyTTSRequest = "volcengine_tts_request"
28- contextKeyResponseFormat = "response_format"
29- DoubaoCodingPlan = "doubao-coding-plan"
30- DoubaoCodingPlanClaudeBaseURL = "https://ark.cn-beijing.volces.com/api/coding"
31- DoubaoCodingPlanOpenAIBaseURL = "https://ark.cn-beijing.volces.com/api/coding/v3"
27+ contextKeyTTSRequest = "volcengine_tts_request"
28+ contextKeyResponseFormat = "response_format"
3229)
3330
3431type Adaptor struct {
@@ -40,7 +37,7 @@ func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dt
4037}
4138
4239func (a * Adaptor ) ConvertClaudeRequest (c * gin.Context , info * relaycommon.RelayInfo , req * dto.ClaudeRequest ) (any , error ) {
43- if info .ChannelBaseUrl == DoubaoCodingPlan {
40+ if _ , ok := channelconstant . ChannelSpecialBases [ info .ChannelBaseUrl ]; ok {
4441 adaptor := claude.Adaptor {}
4542 return adaptor .ConvertClaudeRequest (c , info , req )
4643 }
@@ -243,11 +240,12 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
243240 if baseUrl == "" {
244241 baseUrl = channelconstant .ChannelBaseURLs [channelconstant .ChannelTypeVolcEngine ]
245242 }
243+ specialPlan , hasSpecialPlan := channelconstant .ChannelSpecialBases [baseUrl ]
246244
247245 switch info .RelayFormat {
248246 case types .RelayFormatClaude :
249- if baseUrl == DoubaoCodingPlan {
250- return fmt .Sprintf ("%s/v1/messages" , DoubaoCodingPlanClaudeBaseURL ), nil
247+ if hasSpecialPlan && specialPlan . ClaudeBaseURL != "" {
248+ return fmt .Sprintf ("%s/v1/messages" , specialPlan . ClaudeBaseURL ), nil
251249 }
252250 if strings .HasPrefix (info .UpstreamModelName , "bot" ) {
253251 return fmt .Sprintf ("%s/api/v3/bots/chat/completions" , baseUrl ), nil
@@ -256,8 +254,8 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
256254 default :
257255 switch info .RelayMode {
258256 case constant .RelayModeChatCompletions :
259- if baseUrl == DoubaoCodingPlan {
260- return fmt .Sprintf ("%s/chat/completions" , DoubaoCodingPlanOpenAIBaseURL ), nil
257+ if hasSpecialPlan && specialPlan . OpenAIBaseURL != "" {
258+ return fmt .Sprintf ("%s/chat/completions" , specialPlan . OpenAIBaseURL ), nil
261259 }
262260 if strings .HasPrefix (info .UpstreamModelName , "bot" ) {
263261 return fmt .Sprintf ("%s/api/v3/bots/chat/completions" , baseUrl ), nil
@@ -345,11 +343,13 @@ func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, request
345343}
346344
347345func (a * Adaptor ) DoResponse (c * gin.Context , resp * http.Response , info * relaycommon.RelayInfo ) (usage any , err * types.NewAPIError ) {
348- if info .RelayFormat == types .RelayFormatClaude && info .ChannelBaseUrl == DoubaoCodingPlan {
349- if info .IsStream {
350- return claude .ClaudeStreamHandler (c , resp , info , claude .RequestModeMessage )
346+ if info .RelayFormat == types .RelayFormatClaude {
347+ if _ , ok := channelconstant .ChannelSpecialBases [info .ChannelBaseUrl ]; ok {
348+ if info .IsStream {
349+ return claude .ClaudeStreamHandler (c , resp , info , claude .RequestModeMessage )
350+ }
351+ return claude .ClaudeHandler (c , resp , info , claude .RequestModeMessage )
351352 }
352- return claude .ClaudeHandler (c , resp , info , claude .RequestModeMessage )
353353 }
354354
355355 if info .RelayMode == constant .RelayModeAudioSpeech {
0 commit comments