Skip to content

Commit 6ac0514

Browse files
committed
[sidecar] fix the cache control for only when models are required
1 parent 0f7bae0 commit 6ac0514

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llm_client/src/clients/open_router.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ pub struct OpenRouterResponse {
250250

251251
impl OpenRouterRequest {
252252
pub fn from_chat_request(request: LLMClientCompletionRequest, model: String) -> Self {
253+
let llm_model = request.model().clone();
253254
let tools = request
254255
.messages()
255256
.into_iter()
@@ -312,9 +313,12 @@ impl OpenRouterRequest {
312313
let is_cache_enabled = message.is_cache_point();
313314
let mut content_messaage =
314315
OpenRouterRequestMessageType::text(content.to_owned());
315-
if is_cache_enabled {
316+
317+
// if we explicilty need to tell about cache control
318+
if is_cache_enabled && llm_model.is_cache_control_explicit() {
316319
content_messaage = content_messaage.set_cache_control();
317320
}
321+
318322
vec![content_messaage]
319323
.into_iter()
320324
.chain(images.into_iter().map(|image| {

llm_client/src/clients/types.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ impl<'de> Deserialize<'de> for LLMType {
166166
}
167167

168168
impl LLMType {
169+
pub fn is_cache_control_explicit(&self) -> bool {
170+
matches!(
171+
self,
172+
LLMType::ClaudeSonnet | LLMType::ClaudeHaiku | LLMType::ClaudeOpus
173+
)
174+
}
175+
169176
pub fn is_openai(&self) -> bool {
170177
matches!(
171178
self,

sidecar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sidecar"
3-
version = "0.1.34"
3+
version = "0.1.35"
44
edition = "2021"
55
build = "build.rs"
66

0 commit comments

Comments
 (0)