Skip to content

Commit 933ab43

Browse files
authored
Merge pull request #1925 from seefs001/feature/claude-context-editing
feat: claude context editing
2 parents 3b306bb + 30cb3b8 commit 933ab43

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

dto/claude.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,11 @@ type ClaudeRequest struct {
196196
TopP float64 `json:"top_p,omitempty"`
197197
TopK int `json:"top_k,omitempty"`
198198
//ClaudeMetadata `json:"metadata,omitempty"`
199-
Stream bool `json:"stream,omitempty"`
200-
Tools any `json:"tools,omitempty"`
201-
ToolChoice any `json:"tool_choice,omitempty"`
202-
Thinking *Thinking `json:"thinking,omitempty"`
199+
Stream bool `json:"stream,omitempty"`
200+
Tools any `json:"tools,omitempty"`
201+
ContextManagement json.RawMessage `json:"context_management,omitempty"`
202+
ToolChoice any `json:"tool_choice,omitempty"`
203+
Thinking *Thinking `json:"thinking,omitempty"`
203204
}
204205

205206
func (c *ClaudeRequest) GetTokenCountMeta() *types.TokenCountMeta {

relay/channel/aws/adaptor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
5252
}
5353

5454
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error {
55+
anthropicBeta := c.Request.Header.Get("anthropic-beta")
56+
if anthropicBeta != "" {
57+
req.Set("anthropic-beta", anthropicBeta)
58+
}
5559
model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req)
5660
return nil
5761
}

relay/channel/claude/adaptor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *rel
7272
anthropicVersion = "2023-06-01"
7373
}
7474
req.Set("anthropic-version", anthropicVersion)
75+
anthropicBeta := c.Request.Header.Get("anthropic-beta")
76+
if anthropicBeta != "" {
77+
req.Set("anthropic-beta", anthropicBeta)
78+
}
7579
model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req)
7680
return nil
7781
}

web/src/i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,7 @@
14041404
"Claude思考适配 BudgetTokens = MaxTokens * BudgetTokens 百分比": "Claude thinking adaptation BudgetTokens = MaxTokens * BudgetTokens percentage",
14051405
"思考适配 BudgetTokens 百分比": "Thinking adaptation BudgetTokens percentage",
14061406
"0.1-1之间的小数": "Decimal between 0.1 and 1",
1407+
"0.1以上的小数": "Decimal above 0.1",
14071408
"模型相关设置": "Model related settings",
14081409
"收起侧边栏": "Collapse sidebar",
14091410
"展开侧边栏": "Expand sidebar",

web/src/i18n/locales/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,7 @@
14041404
"Claude思考适配 BudgetTokens = MaxTokens * BudgetTokens 百分比": "Adaptation de la pensée Claude BudgetTokens = MaxTokens * BudgetTokens pourcentage",
14051405
"思考适配 BudgetTokens 百分比": "Adaptation de la pensée BudgetTokens pourcentage",
14061406
"0.1-1之间的小数": "Décimal entre 0,1 et 1",
1407+
"0.1以上的小数": "Décimal supérieur à 0,1",
14071408
"模型相关设置": "Paramètres liés au modèle",
14081409
"收起侧边栏": "Réduire la barre latérale",
14091410
"展开侧边栏": "Développer la barre latérale",

web/src/pages/Setting/Model/SettingClaudeModel.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ export default function SettingClaudeModel(props) {
202202
label={t('思考适配 BudgetTokens 百分比')}
203203
field={'claude.thinking_adapter_budget_tokens_percentage'}
204204
initValue={''}
205-
extraText={t('0.1-1之间的小数')}
205+
extraText={t('0.1以上的小数')}
206206
min={0.1}
207-
max={1}
208207
onChange={(value) =>
209208
setInputs({
210209
...inputs,

0 commit comments

Comments
 (0)