|
|
|
@@ -144,6 +144,12 @@ type RelayInfo struct { |
|
|
|
SubscriptionAmountUsedAfterPreConsume int64 |
|
|
|
IsClaudeBetaQuery bool // /v1/messages?beta=true |
|
|
|
IsChannelTest bool // channel test request |
|
|
|
RetryIndex int |
|
|
|
LastError *types.NewAPIError |
|
|
|
RequestHeaders map[string]string |
|
|
|
RuntimeHeadersOverride map[string]interface{} |
|
|
|
UseRuntimeHeadersOverride bool |
|
|
|
ParamOverrideAudit []string |
|
|
|
|
|
|
|
PriceData types.PriceData |
|
|
|
|
|
|
|
@@ -473,6 +479,7 @@ func genBaseRelayInfo(c *gin.Context, request dto.Request) *RelayInfo { |
|
|
|
//promptTokens: common.GetContextKeyInt(c, constant.ContextKeyPromptTokens), |
|
|
|
estimatePromptTokens: common.GetContextKeyInt(c, constant.ContextKeyEstimatedTokens), |
|
|
|
}, |
|
|
|
RequestHeaders: cloneRequestHeaders(c), |
|
|
|
} |
|
|
|
|
|
|
|
if info.RelayMode == relayconstant.RelayModeUnknown { |
|
|
|
@@ -493,6 +500,27 @@ func genBaseRelayInfo(c *gin.Context, request dto.Request) *RelayInfo { |
|
|
|
return info |
|
|
|
} |
|
|
|
|
|
|
|
func cloneRequestHeaders(c *gin.Context) map[string]string { |
|
|
|
if c == nil || c.Request == nil { |
|
|
|
return nil |
|
|
|
} |
|
|
|
if len(c.Request.Header) == 0 { |
|
|
|
return nil |
|
|
|
} |
|
|
|
headers := make(map[string]string, len(c.Request.Header)) |
|
|
|
for key := range c.Request.Header { |
|
|
|
value := strings.TrimSpace(c.Request.Header.Get(key)) |
|
|
|
if value == "" { |
|
|
|
continue |
|
|
|
} |
|
|
|
headers[key] = value |
|
|
|
} |
|
|
|
if len(headers) == 0 { |
|
|
|
return nil |
|
|
|
} |
|
|
|
return headers |
|
|
|
} |
|
|
|
|
|
|
|
func GenRelayInfo(c *gin.Context, relayFormat types.RelayFormat, request dto.Request, ws *websocket.Conn) (*RelayInfo, error) { |
|
|
|
var info *RelayInfo |
|
|
|
var err error |
|
|
|
|