feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
+61
-15
@@ -47,9 +47,8 @@ type RerankerInfo struct {
|
||||
}
|
||||
|
||||
type BuildInToolInfo struct {
|
||||
ToolName string
|
||||
CallCount int
|
||||
SearchContextSize string
|
||||
ToolName string
|
||||
CallCount int
|
||||
}
|
||||
|
||||
type ResponsesUsageInfo struct {
|
||||
@@ -91,6 +90,7 @@ type RelayInfo struct {
|
||||
TokenUnlimited bool
|
||||
StartTime time.Time
|
||||
FirstResponseTime time.Time
|
||||
UpstreamTiming *UpstreamTiming
|
||||
isFirstResponse bool
|
||||
//SendLastReasoningResponse bool
|
||||
IsStream bool
|
||||
@@ -201,6 +201,27 @@ type RelayInfo struct {
|
||||
FinalRequestRelayFormat types.RelayFormat
|
||||
|
||||
StreamStatus *StreamStatus
|
||||
// VendorToolUsage reads the upstream's own billed tool counts from a raw
|
||||
// response body (non-stream) or the raw terminal stream frame. The channel
|
||||
// adaptor's Init sets it for upstreams whose usage extension names a billed
|
||||
// count; it stays nil for everyone else. Keys are tool-price keys. A zero
|
||||
// value suppresses the protocol items counted under that key, so a vendor
|
||||
// count can supersede web_search_call items billed under a different key.
|
||||
VendorToolUsage func(raw []byte) map[string]int
|
||||
// WebSearchBillingKey overrides the tool-price key of hosted web search:
|
||||
// usage.server_tool_use.web_search_requests and web_search_tool_result
|
||||
// blocks in the Claude handler, and web_search_call items counted by
|
||||
// CountBillableToolCall. Set by a channel adaptor whose upstream bills
|
||||
// search under its own price list; empty keeps the protocol defaults.
|
||||
WebSearchBillingKey string
|
||||
// WebFetchBillingKey overrides the tool-price key of
|
||||
// usage.server_tool_use.web_fetch_requests in the Claude handler, for an
|
||||
// upstream that bills page fetches under its own price list; empty keeps
|
||||
// the protocol default web_fetch.
|
||||
WebFetchBillingKey string
|
||||
// requestInferredToolKey is the tool-price key RecordRequestInferredToolCall
|
||||
// billed for the current channel attempt.
|
||||
requestInferredToolKey string
|
||||
// PerformanceOutputTokens is captured by settlement and sampled once at
|
||||
// the request boundary, independently of billing success or failure.
|
||||
PerformanceOutputTokens int64
|
||||
@@ -208,6 +229,9 @@ type RelayInfo struct {
|
||||
|
||||
// convOptions caches the converter settings snapshot (see ConvOptions).
|
||||
convOptions *convmeta.Options
|
||||
// responsesToolState is written by request conversion and read by the
|
||||
// matching response conversion (see ResponsesToolState).
|
||||
responsesToolState *convmeta.ResponsesToolState
|
||||
|
||||
conversionDiagnostics []types.ConversionDiagnostic
|
||||
conversionDiagnosticKeys map[conversionDiagnosticKey]struct{}
|
||||
@@ -317,6 +341,14 @@ func (info *RelayInfo) InitChannelMeta(c *gin.Context) {
|
||||
// Channel identity feeds the converter options snapshot (e.g.
|
||||
// OpenRouterDialect); drop the cache so a cross-channel retry rebuilds it.
|
||||
info.convOptions = nil
|
||||
// The adaptor Init of this attempt sets the vendor billing hooks again.
|
||||
info.VendorToolUsage = nil
|
||||
info.WebSearchBillingKey = ""
|
||||
info.WebFetchBillingKey = ""
|
||||
if info.requestInferredToolKey != "" && info.ResponsesUsageInfo != nil {
|
||||
delete(info.ResponsesUsageInfo.BuiltInTools, info.requestInferredToolKey)
|
||||
}
|
||||
info.requestInferredToolKey = ""
|
||||
if model_setting.GetGlobalSettings().PassThroughRequestEnabled || channelMeta.ChannelSetting.PassThroughBodyEnabled {
|
||||
info.ReasoningEffort = ""
|
||||
info.ReasoningConversion = nil
|
||||
@@ -497,14 +529,6 @@ func GenRelayInfoResponses(c *gin.Context, request *dto.OpenAIResponsesRequest)
|
||||
ToolName: toolType,
|
||||
CallCount: 0,
|
||||
}
|
||||
switch toolType {
|
||||
case dto.BuildInToolWebSearchPreview:
|
||||
searchContextSize := common.Interface2String(tool["search_context_size"])
|
||||
if searchContextSize == "" {
|
||||
searchContextSize = "medium"
|
||||
}
|
||||
info.ResponsesUsageInfo.BuiltInTools[toolType].SearchContextSize = searchContextSize
|
||||
}
|
||||
}
|
||||
}
|
||||
return info
|
||||
@@ -716,6 +740,9 @@ func GenRelayInfo(c *gin.Context, relayFormat types.RelayFormat, request dto.Req
|
||||
return GenRelayInfoAlphaSearch(c, request), nil
|
||||
}
|
||||
return nil, errors.New("request is not a AlphaSearchRequest")
|
||||
case types.RelayFormatDeepSeekTools:
|
||||
info = genBaseRelayInfo(c, request)
|
||||
info.RelayFormat = types.RelayFormatDeepSeekTools
|
||||
case types.RelayFormatTask:
|
||||
info = genBaseRelayInfo(c, nil)
|
||||
info.TaskRelayInfo = &TaskRelayInfo{}
|
||||
@@ -913,6 +940,19 @@ func (info *RelayInfo) EnsureClaudeConvertInfo() *convmeta.ClaudeConvertInfo {
|
||||
return info.ClaudeConvertInfo
|
||||
}
|
||||
|
||||
func (info *RelayInfo) ResponsesToolState() *convmeta.ResponsesToolState {
|
||||
if info == nil {
|
||||
return nil
|
||||
}
|
||||
return info.responsesToolState
|
||||
}
|
||||
|
||||
func (info *RelayInfo) SetResponsesToolState(state *convmeta.ResponsesToolState) {
|
||||
if info != nil {
|
||||
info.responsesToolState = state
|
||||
}
|
||||
}
|
||||
|
||||
func (info *RelayInfo) GetSendResponseCount() int {
|
||||
if info == nil {
|
||||
return 0
|
||||
@@ -936,6 +976,7 @@ func (info *RelayInfo) ConvOptions() *convmeta.Options {
|
||||
|
||||
claudeSettings := model_setting.GetClaudeSettings()
|
||||
geminiSettings := model_setting.GetGeminiSettings()
|
||||
channelType := info.GetChannelType()
|
||||
options := &convmeta.Options{
|
||||
Claude: convmeta.ClaudeOptions{
|
||||
ThinkingAdapterEnabled: claudeSettings.ThinkingAdapterEnabled,
|
||||
@@ -948,6 +989,11 @@ func (info *RelayInfo) ConvOptions() *convmeta.Options {
|
||||
FunctionCallThoughtSignatureEnabled: geminiSettings.FunctionCallThoughtSignatureEnabled,
|
||||
SupportsImagine: model_setting.IsGeminiModelSupportImagine,
|
||||
SafetySetting: model_setting.GetGeminiSafetySetting,
|
||||
// Gemini API v1 has no parametersJsonSchema; v1beta and Vertex AI
|
||||
// accept it.
|
||||
SupportsJSONSchema: func(modelName string) bool {
|
||||
return channelType == constant.ChannelTypeVertexAi || model_setting.GetGeminiVersionSetting(modelName) != "v1"
|
||||
},
|
||||
},
|
||||
OpenRouterDialect: info != nil && info.GetChannelType() == constant.ChannelTypeOpenRouter,
|
||||
PreserveThinkingSuffix: model_setting.ShouldPreserveThinkingSuffix,
|
||||
@@ -1120,7 +1166,7 @@ func RemoveDisabledFields(jsonData []byte, channelOtherSettings dto.ChannelOther
|
||||
|
||||
var data map[string]any
|
||||
if err := common.Unmarshal(jsonData, &data); err != nil {
|
||||
common.SysError("RemoveDisabledFields Unmarshal error :" + err.Error())
|
||||
common.SysError(common.LogText("RemoveDisabledFields Unmarshal error :%s", err.Error()))
|
||||
return jsonData, nil
|
||||
}
|
||||
|
||||
@@ -1177,7 +1223,7 @@ func RemoveDisabledFields(jsonData []byte, channelOtherSettings dto.ChannelOther
|
||||
|
||||
jsonDataAfter, err := common.Marshal(data)
|
||||
if err != nil {
|
||||
common.SysError("RemoveDisabledFields Marshal error :" + err.Error())
|
||||
common.SysError(common.LogText("RemoveDisabledFields Marshal error :%s", err.Error()))
|
||||
return jsonData, nil
|
||||
}
|
||||
return jsonDataAfter, nil
|
||||
@@ -1211,7 +1257,7 @@ func RemoveGeminiDisabledFields(jsonData []byte) ([]byte, error) {
|
||||
|
||||
var data map[string]any
|
||||
if err := common.Unmarshal(jsonData, &data); err != nil {
|
||||
common.SysError("RemoveGeminiDisabledFields Unmarshal error: " + err.Error())
|
||||
common.SysError(common.LogText("RemoveGeminiDisabledFields Unmarshal error: %s", err.Error()))
|
||||
return jsonData, nil
|
||||
}
|
||||
|
||||
@@ -1240,7 +1286,7 @@ func RemoveGeminiDisabledFields(jsonData []byte) ([]byte, error) {
|
||||
|
||||
jsonDataAfter, err := common.Marshal(data)
|
||||
if err != nil {
|
||||
common.SysError("RemoveGeminiDisabledFields Marshal error: " + err.Error())
|
||||
common.SysError(common.LogText("RemoveGeminiDisabledFields Marshal error: %s", err.Error()))
|
||||
return jsonData, nil
|
||||
}
|
||||
return jsonDataAfter, nil
|
||||
|
||||
Reference in new issue
Block a user