From a97e2f875919988f6b8acc30558e06c928fcadfc Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:37:58 -0400 Subject: [PATCH] Pass through Anthropic cache configuration when using Zed provider (cherry-pick #16685) (#16689) Cherry-picked Pass through Anthropic cache configuration when using Zed provider (#16685) This PR makes it so the model's cache configuration gets passed through from the base model when using the Zed provider. Release Notes: - Fixed caching for Anthropic models when using the Zed provider. Co-authored-by: Marshall Bowers --- crates/language_model/src/provider/cloud.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/language_model/src/provider/cloud.rs b/crates/language_model/src/provider/cloud.rs index a42459b29b19fc82d87d824c1151261d77c1ef23..4a014d3de8643fcb1805512aaf01528d802e4dfb 100644 --- a/crates/language_model/src/provider/cloud.rs +++ b/crates/language_model/src/provider/cloud.rs @@ -444,6 +444,21 @@ impl LanguageModel for CloudLanguageModel { self.model.max_token_count() } + fn cache_configuration(&self) -> Option { + match &self.model { + CloudModel::Anthropic(model) => { + model + .cache_configuration() + .map(|cache| LanguageModelCacheConfiguration { + max_cache_anchors: cache.max_cache_anchors, + should_speculate: cache.should_speculate, + min_total_token: cache.min_total_token, + }) + } + CloudModel::OpenAi(_) | CloudModel::Google(_) | CloudModel::Zed(_) => None, + } + } + fn count_tokens( &self, request: LanguageModelRequest,