Skip to content

Commit 8117398

Browse files
committed
Make prompt caching opt-in by replacing disable_cache with is_explicit_cache_enabled
- reverse: 'disable cache' to 'enable cache', so it's disabled by default - rename 'enable cache' to 'is explicit cache enabled'
1 parent 2aea693 commit 8117398

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎apps/editor/src/commands/code-at-cursor-command/utils/perform-code-at-cursor.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ export const perform_code_at_cursor = async (params: {
430430
const user_content = build_user_content({
431431
model_provider,
432432
part1,
433-
part2
433+
part2,
434+
is_explicit_cache_enabled: true
434435
})
435436

436437
const messages = [

‎apps/editor/src/features/search-files/utils/search-files-by-intelligent.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export const search_files_by_intelligent = async (
3535
const user_content = build_user_content({
3636
model_provider,
3737
part1: xml_files,
38-
part2,
39-
disable_cache: true
38+
part2
4039
})
4140

4241
const messages = [{ role: 'user', content: user_content }]

‎apps/editor/src/utils/build-user-content.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const build_user_content = (params: {
55
model_provider: ModelProvider
66
part1: string
77
part2: string
8-
disable_cache?: boolean
8+
is_explicit_cache_enabled?: boolean
99
}): any => {
1010
const parse_text_with_images = (text: string) => {
1111
if (!text.includes('<cwc-image>')) {
@@ -38,7 +38,7 @@ export const build_user_content = (params: {
3838
if (is_anthropic || is_openai) {
3939
const cache_config: any = {}
4040

41-
if (!params.disable_cache) {
41+
if (params.is_explicit_cache_enabled) {
4242
if (is_anthropic) {
4343
cache_config.cache_control = { type: 'ephemeral' }
4444
if (params.model_provider.extended_cache) {

‎apps/editor/src/views/prompt/backend/message-handlers/handle-make-api-call.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ export const handle_make_api_call = async (
240240
user_instructions: processed_instructions,
241241
separator: true
242242
})
243-
user_content = build_user_content({ model_provider, part1, part2 })
243+
user_content = build_user_content({
244+
model_provider,
245+
part1,
246+
part2,
247+
is_explicit_cache_enabled: true
248+
})
244249
}
245250

246251
const messages = [

0 commit comments

Comments
 (0)