add missing ttl setting and filter dropdown models when 1hr ttl is set in settings.json
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use aws_sdk_bedrockruntime::types::{
|
||||
CachePointBlock, CachePointType, ContentBlock, ConversationRole, InferenceConfiguration,
|
||||
Message as BedrockMessage, SystemContentBlock, Tool, ToolConfiguration, ToolInputSchema,
|
||||
ToolResultBlock, ToolResultContentBlock, ToolResultStatus, ToolSpecification, ToolUseBlock,
|
||||
CachePointBlock, CachePointType, CacheTtl, ContentBlock, ConversationRole,
|
||||
InferenceConfiguration, Message as BedrockMessage, SystemContentBlock, Tool,
|
||||
ToolConfiguration, ToolInputSchema, ToolResultBlock, ToolResultContentBlock,
|
||||
ToolResultStatus, ToolSpecification, ToolUseBlock,
|
||||
};
|
||||
use aws_smithy_types::Document;
|
||||
use serde_json::Value as JsonValue;
|
||||
@@ -244,11 +245,15 @@ fn convert_messages(messages: Vec<ConversationMessage>, caching_config: &Caching
|
||||
let cache_idx = messages.len() - 2;
|
||||
let msg = messages.remove(cache_idx);
|
||||
let mut content = msg.content().to_vec();
|
||||
|
||||
let mut builder = CachePointBlock::builder().r#type(CachePointType::Default);
|
||||
if caching_config.extended_ttl_requested {
|
||||
builder = builder.ttl(CacheTtl::OneHour);
|
||||
log::info!("[bedrock] Using 1-hour cache TTL (ENABLE_PROMPT_CACHING_1H=1)");
|
||||
}
|
||||
|
||||
content.push(ContentBlock::CachePoint(
|
||||
CachePointBlock::builder()
|
||||
.r#type(CachePointType::Default)
|
||||
.build()
|
||||
.expect("valid cache point"),
|
||||
builder.build().expect("valid cache point"),
|
||||
));
|
||||
let cached_msg = BedrockMessage::builder()
|
||||
.role(msg.role().clone())
|
||||
@@ -256,11 +261,6 @@ fn convert_messages(messages: Vec<ConversationMessage>, caching_config: &Caching
|
||||
.build()
|
||||
.expect("valid message with cache point");
|
||||
messages.insert(cache_idx, cached_msg);
|
||||
|
||||
if caching_config.extended_ttl_requested {
|
||||
log::info!("[bedrock] Extended 1-hour caching requested (ENABLE_PROMPT_CACHING_1H=1)");
|
||||
// TODO: Use explicit TTL when AWS SDK supports it
|
||||
}
|
||||
}
|
||||
|
||||
messages
|
||||
@@ -302,11 +302,12 @@ fn convert_system_prompt(system_prompt: Option<String>, caching_config: &Caching
|
||||
Some(prompt) if !prompt.is_empty() => {
|
||||
let mut blocks = vec![SystemContentBlock::Text(prompt)];
|
||||
if caching_config.enabled {
|
||||
let mut builder = CachePointBlock::builder().r#type(CachePointType::Default);
|
||||
if caching_config.extended_ttl_requested {
|
||||
builder = builder.ttl(CacheTtl::OneHour);
|
||||
}
|
||||
blocks.push(SystemContentBlock::CachePoint(
|
||||
CachePointBlock::builder()
|
||||
.r#type(CachePointType::Default)
|
||||
.build()
|
||||
.expect("valid cache point"),
|
||||
builder.build().expect("valid cache point"),
|
||||
));
|
||||
}
|
||||
blocks
|
||||
@@ -357,11 +358,12 @@ fn build_tool_config(tools: Vec<ToolDefinition>, caching_config: &CachingConfig)
|
||||
.collect();
|
||||
|
||||
if caching_config.enabled {
|
||||
let mut builder = CachePointBlock::builder().r#type(CachePointType::Default);
|
||||
if caching_config.extended_ttl_requested {
|
||||
builder = builder.ttl(CacheTtl::OneHour);
|
||||
}
|
||||
tool_specs.push(Tool::CachePoint(
|
||||
CachePointBlock::builder()
|
||||
.r#type(CachePointType::Default)
|
||||
.build()
|
||||
.expect("valid cache point"),
|
||||
builder.build().expect("valid cache point"),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -89,10 +89,20 @@ impl View for SettingsView {
|
||||
}
|
||||
|
||||
// Model Configuration
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"\n━━━ Model Selection ━━━",
|
||||
appearance.ui_font_family(),
|
||||
font_size - 1.0,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.finish(),
|
||||
);
|
||||
|
||||
if let Some(model) = &self.external_config.anthropic_model {
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
format!("Primary Model: {}", model),
|
||||
format!("Default Model (ANTHROPIC_MODEL): {}", model),
|
||||
appearance.ui_font_family(),
|
||||
font_size,
|
||||
)
|
||||
@@ -100,6 +110,35 @@ impl View for SettingsView {
|
||||
.soft_wrap(true)
|
||||
.finish(),
|
||||
);
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"Sets the initial model in dropdown. You can change it.",
|
||||
appearance.ui_font_family(),
|
||||
font_size - 1.0,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.soft_wrap(true)
|
||||
.finish(),
|
||||
);
|
||||
} else {
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"Default Model: Not set",
|
||||
appearance.ui_font_family(),
|
||||
font_size,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.finish(),
|
||||
);
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"Set ANTHROPIC_MODEL in settings.json to set initial model",
|
||||
appearance.ui_font_family(),
|
||||
font_size - 1.0,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.finish(),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(model) = &self.external_config.anthropic_small_fast_model {
|
||||
@@ -134,13 +173,33 @@ impl View for SettingsView {
|
||||
if self.caching_config.extended_ttl_requested {
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"Extended 1h TTL: ✓ Requested",
|
||||
"Extended 1h Cache TTL: ✓ Active",
|
||||
appearance.ui_font_family(),
|
||||
font_size,
|
||||
)
|
||||
.with_color(text_color)
|
||||
.finish(),
|
||||
);
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"All cache points use 1-hour TTL. Model list filtered to compatible models only.",
|
||||
appearance.ui_font_family(),
|
||||
font_size - 1.0,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.soft_wrap(true)
|
||||
.finish(),
|
||||
);
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"Compatible: Claude Opus 4.5, Sonnet 4.5, Haiku 4.5",
|
||||
appearance.ui_font_family(),
|
||||
font_size - 1.0,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.soft_wrap(true)
|
||||
.finish(),
|
||||
);
|
||||
}
|
||||
|
||||
// Additional Models
|
||||
@@ -173,7 +232,16 @@ impl View for SettingsView {
|
||||
// Help text
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"\nSettings loaded from ~/.claude/settings.json",
|
||||
"\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
|
||||
appearance.ui_font_family(),
|
||||
font_size,
|
||||
)
|
||||
.with_color(label_color)
|
||||
.finish(),
|
||||
);
|
||||
column = column.with_child(
|
||||
Text::new(
|
||||
"Settings loaded from ~/.claude/settings.json",
|
||||
appearance.ui_font_family(),
|
||||
font_size - 1.0,
|
||||
)
|
||||
|
||||
@@ -40,8 +40,10 @@ pub async fn execute(
|
||||
.map(|tc| tc.tasks.is_empty())
|
||||
.unwrap_or(true);
|
||||
|
||||
// Use the model from params (selected in UI or defaulted from ANTHROPIC_MODEL)
|
||||
let mut model_id = params.model_id;
|
||||
if model_id.is_empty() || model_id == "auto" {
|
||||
// Fall back to default if nothing is set
|
||||
model_id = "us.anthropic.claude-opus-4-6".to_string();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user