Skip to content

Commit b8a6e73

Browse files
committed
Implement 'Deep Think' option support for the Z.AI chatbot
1 parent 22a6566 commit b8a6e73

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

  • packages
    • browser/src/content-scripts/send-prompt-content-script/chatbots
    • shared/src/constants

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/z-ai.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ export const z_ai: Chatbot = {
2121
check_for_element()
2222
})
2323
},
24+
set_options: async (options?: string[]) => {
25+
if (!options) return
26+
27+
const deep_think_button = document.querySelector(
28+
'button[data-autothink]'
29+
) as HTMLButtonElement
30+
if (!deep_think_button) {
31+
report_initialization_error({
32+
function_name: 'z_ai.set_options',
33+
log_message: 'Auto think button not found',
34+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
35+
})
36+
return
37+
}
38+
39+
const should_be_on = options.includes('deep-think')
40+
const is_on = deep_think_button.getAttribute('data-autothink') == 'true'
41+
42+
if (should_be_on != is_on) {
43+
deep_think_button.click()
44+
await new Promise((r) => requestAnimationFrame(r))
45+
}
46+
},
2447
inject_apply_response_button: (
2548
client_id: number,
2649
raw_instructions?: string

‎packages/shared/src/constants/chatbots.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ export const CHATBOTS = {
326326
supports_reasoning_effort: false,
327327
supports_thinking_budget: false,
328328
default_system_instructions: '',
329-
supported_options: {},
329+
supported_options: {
330+
'deep-think': 'Deep Think'
331+
},
330332
default_top_p: 0,
331333
models: {}
332334
}

0 commit comments

Comments
 (0)