mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
feat(api): enhance statistics storage management with scope options
- Introduced a new type `StatisticsStorageScope` to specify the scope for clearing statistics. - Updated the `clearStatisticsStorage` API method to accept a scope parameter, allowing for selective clearing of detailed records or all statistics. - Modified the demo API to handle the new scope parameter appropriately. - Updated the SettingsPage component to include a selection for clearing scope, enhancing user control over statistics management. - Added new translations for the updated messages related to statistics clearing in both English and Chinese.
This commit is contained in:
1 parent
217f984112
commit
71ddf71ec1
15 files changed
+514
-111
No files matched your search
@@ -49,7 +49,8 @@ impl Provider for AnthropicProvider {
|
||||
let recorder = self.recorder.clone();
|
||||
Box::pin(try_stream! {
|
||||
let ModelInvocation { call_id, request, .. } = invocation;
|
||||
let messages = anthropic_messages(&request.history)?;
|
||||
let mut messages = anthropic_messages(&request.history)?;
|
||||
mark_cache_breakpoint(&mut messages);
|
||||
let max_tokens = request.model.max_output_tokens.or(config.max_output_tokens)
|
||||
.unwrap_or(DEFAULT_MAX_OUTPUT_TOKENS);
|
||||
let mut body = json!({
|
||||
@@ -372,6 +373,24 @@ fn anthropic_messages(messages: &[ProjectedMessage]) -> Result<Vec<Value>> {
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
fn mark_cache_breakpoint(messages: &mut [Value]) {
|
||||
for message in messages {
|
||||
let Some(content) = message.get_mut("content").and_then(Value::as_array_mut) else {
|
||||
continue;
|
||||
};
|
||||
for block in content {
|
||||
let kind = block.get("type").and_then(Value::as_str);
|
||||
if matches!(kind, Some("thinking" | "redacted_thinking")) {
|
||||
continue;
|
||||
}
|
||||
if let Some(block) = block.as_object_mut() {
|
||||
block.insert("cache_control".into(), json!({"type": "ephemeral"}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn anthropic_parts(role: &Role, parts: &[ContentPart]) -> Result<Vec<Value>> {
|
||||
parts
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user