From 93642c9c51c1091aa310fb39fc6ae8a7ace7ab37 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 22 Aug 2024 12:48:47 -0400 Subject: [PATCH] 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. --- 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 0517986f28..6cefa8de7d 100644 --- a/crates/language_model/src/provider/cloud.rs +++ b/crates/language_model/src/provider/cloud.rs @@ -445,6 +445,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,