Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dto/channel_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ChannelOtherSettings struct {
AzureResponsesVersion string `json:"azure_responses_version,omitempty"`
VertexKeyType VertexKeyType `json:"vertex_key_type,omitempty"` // "json" or "api_key"
OpenRouterEnterprise *bool `json:"openrouter_enterprise,omitempty"`
ClaudeBetaQuery bool `json:"claude_beta_query,omitempty"` // Claude 渠道是否强制追加 ?beta=true
AllowServiceTier bool `json:"allow_service_tier,omitempty"` // 是否允许 service_tier 透传(默认过滤以避免额外计费)
DisableStore bool `json:"disable_store,omitempty"` // 是否禁用 store 透传(默认允许透传,禁用后可能导致 Codex 无法使用)
AllowSafetyIdentifier bool `json:"allow_safety_identifier,omitempty"` // 是否允许 safety_identifier 透传(默认过滤以保护用户隐私)
Expand Down
9 changes: 6 additions & 3 deletions relay/common/relay_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,15 @@ func GenRelayInfoClaude(c *gin.Context, request dto.Request) *RelayInfo {
info.ClaudeConvertInfo = &ClaudeConvertInfo{
LastMessagesType: LastMessageTypeNone,
}
if c.Query("beta") == "true" {
info.IsClaudeBetaQuery = true
}
info.IsClaudeBetaQuery = c.Query("beta") == "true" || isClaudeBetaForced(c)
return info
}

func isClaudeBetaForced(c *gin.Context) bool {
channelOtherSettings, ok := common.GetContextKeyType[dto.ChannelOtherSettings](c, constant.ContextKeyChannelOtherSetting)
return ok && channelOtherSettings.ClaudeBetaQuery
}

func GenRelayInfoRerank(c *gin.Context, request *dto.RerankRequest) *RelayInfo {
info := genBaseRelayInfo(c, request)
info.RelayMode = relayconstant.RelayModeRerank
Expand Down
26 changes: 26 additions & 0 deletions web/src/components/table/channels/modals/EditChannelModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const EditChannelModal = (props) => {
allow_service_tier: false,
disable_store: false, // false = 允许透传(默认开启)
allow_safety_identifier: false,
claude_beta_query: false,
};
const [batch, setBatch] = useState(false);
const [multiToSingle, setMultiToSingle] = useState(false);
Expand Down Expand Up @@ -633,6 +634,7 @@ const EditChannelModal = (props) => {
data.disable_store = parsedSettings.disable_store || false;
data.allow_safety_identifier =
parsedSettings.allow_safety_identifier || false;
data.claude_beta_query = parsedSettings.claude_beta_query || false;
} catch (error) {
console.error('解析其他设置失败:', error);
data.azure_responses_version = '';
Expand All @@ -643,6 +645,7 @@ const EditChannelModal = (props) => {
data.allow_service_tier = false;
data.disable_store = false;
data.allow_safety_identifier = false;
data.claude_beta_query = false;
}
} else {
// 兼容历史数据:老渠道没有 settings 时,默认按 json 展示
Expand All @@ -652,6 +655,7 @@ const EditChannelModal = (props) => {
data.allow_service_tier = false;
data.disable_store = false;
data.allow_safety_identifier = false;
data.claude_beta_query = false;
}

if (
Expand Down Expand Up @@ -1394,6 +1398,9 @@ const EditChannelModal = (props) => {
settings.allow_safety_identifier =
localInputs.allow_safety_identifier === true;
}
if (localInputs.type === 14) {
settings.claude_beta_query = localInputs.claude_beta_query === true;
}
}

localInputs.settings = JSON.stringify(settings);
Expand All @@ -1414,6 +1421,7 @@ const EditChannelModal = (props) => {
delete localInputs.allow_service_tier;
delete localInputs.disable_store;
delete localInputs.allow_safety_identifier;
delete localInputs.claude_beta_query;

let res;
localInputs.auto_ban = localInputs.auto_ban ? 1 : 0;
Expand Down Expand Up @@ -3305,6 +3313,24 @@ const EditChannelModal = (props) => {
</div>
</div>

{inputs.type === 14 && (
<Form.Switch
field='claude_beta_query'
label={t('Claude 强制 beta=true')}
checkedText={t('开')}
uncheckedText={t('关')}
onChange={(value) =>
handleChannelOtherSettingsChange(
'claude_beta_query',
value,
)
}
extraText={t(
'开启后,该渠道请求 Claude 时将强制追加 ?beta=true(无需客户端手动传参)',
)}
/>
)}

{inputs.type === 1 && (
<Form.Switch
field='force_format'
Expand Down