Skip to content

Commit 74108bd

Browse files
committed
Refactor chatbot configuration functions to accept the entire Chat object instead of individual parameters, and update Perplexity model support with reasoning options
1 parent 4544765 commit 74108bd

21 files changed

Lines changed: 182 additions & 49 deletions

File tree

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const ai_studio: Chatbot = {
2929
check_for_element()
3030
})
3131
},
32-
enter_system_instructions: async (system_instructions?: string) => {
32+
enter_system_instructions: async (chat) => {
33+
const system_instructions = chat.system_instructions
3334
if (!system_instructions) return
3435
await open_panel()
3536
const system_instructions_button = document.querySelector(
@@ -84,7 +85,8 @@ export const ai_studio: Chatbot = {
8485
close_button.click()
8586
await new Promise((r) => requestAnimationFrame(r))
8687
},
87-
set_options: async (options?: string[]) => {
88+
set_options: async (chat) => {
89+
const options = chat.options
8890
if (!options) return
8991
const settings_items = Array.from(
9092
document.querySelectorAll('div.settings-item')
@@ -178,7 +180,8 @@ export const ai_studio: Chatbot = {
178180
}
179181
await new Promise((r) => requestAnimationFrame(r))
180182
},
181-
set_temperature: async (temperature?: number) => {
183+
set_temperature: async (chat) => {
184+
const temperature = chat.temperature
182185
if (temperature === undefined) return
183186
const temperature_element = document.querySelector(
184187
'ms-prompt-run-settings div[data-test-id="temperatureSliderContainer"] input[type=number]'
@@ -193,7 +196,8 @@ export const ai_studio: Chatbot = {
193196
temperature_element.value = temperature.toString()
194197
temperature_element.dispatchEvent(new Event('change', { bubbles: true }))
195198
},
196-
set_reasoning_effort: async (reasoning_effort?: string) => {
199+
set_reasoning_effort: async (chat) => {
200+
const reasoning_effort = chat.reasoning_effort
197201
if (!reasoning_effort) return
198202

199203
await open_panel()
@@ -239,7 +243,8 @@ export const ai_studio: Chatbot = {
239243

240244
await new Promise((r) => requestAnimationFrame(r))
241245
},
242-
set_thinking_budget: async (thinking_budget?: number) => {
246+
set_thinking_budget: async (chat) => {
247+
const thinking_budget = chat.thinking_budget
243248
if (thinking_budget === undefined) {
244249
const thinking_toggle = document.querySelector(
245250
'mat-slide-toggle[data-test-toggle="enable-thinking"] button'
@@ -306,7 +311,8 @@ export const ai_studio: Chatbot = {
306311
budget_input.dispatchEvent(new Event('change', { bubbles: true }))
307312
}
308313
},
309-
set_top_p: async (top_p?: number) => {
314+
set_top_p: async (chat) => {
315+
const top_p = chat.top_p
310316
if (top_p === undefined) return
311317
const settings_items = Array.from(
312318
document.querySelectorAll('div.settings-item')

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export const chatgpt: Chatbot = {
3838
})
3939
}
4040
},
41-
set_options: async (options?: string[]) => {
41+
set_options: async (chat) => {
42+
const options = chat.options
4243
if (!options) return
4344
const supported_options = CHATBOTS['ChatGPT'].supported_options
4445
for (const option of options) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const claude: Chatbot = {
1919
check_for_element()
2020
})
2121
},
22-
set_model: async (model?: string) => {
22+
set_model: async (chat) => {
23+
const model = chat.model
2324
if (!model) return
2425
const model_selector_button = document.querySelector(
2526
'button[data-testid="model-selector-dropdown"]'
@@ -70,7 +71,8 @@ export const claude: Chatbot = {
7071
}
7172
await new Promise((r) => requestAnimationFrame(r))
7273
},
73-
set_options: async (options?: string[]) => {
74+
set_options: async (chat) => {
75+
const options = chat.options
7476
if (!options) return
7577
const supported_options = CHATBOTS['Claude'].supported_options
7678
if (

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const copilot: Chatbot = {
1919
check_for_element()
2020
})
2121
},
22-
set_model: async (model?: string) => {
22+
set_model: async (chat) => {
23+
const model = chat.model
2324
if (!model) return
2425

2526
const model_selector_button = document.querySelector(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
import { report_initialization_error } from '../utils/report-initialization-error'
88

99
export const deepseek: Chatbot = {
10-
set_options: async (options?: string[]) => {
10+
set_options: async (chat) => {
11+
const options = chat.options
1112
if (!options) return
1213

1314
const deep_think_button = Array.from(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export const doubao: Chatbot = {
2323
check_for_element()
2424
})
2525
},
26-
set_options: async (options?: string[]) => {
26+
set_options: async (chat) => {
27+
const options = chat.options
2728
if (!options) return
2829
const deep_thinking_button = document.querySelector(
2930
'div[data-testid="chat_input"] input[data-testid="upload-file-input"] + button'

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const gemini: Chatbot = {
1919
check_for_element()
2020
})
2121
},
22-
set_model: async (model?: string) => {
22+
set_model: async (chat) => {
23+
const model = chat.model
2324
if (
2425
model &&
2526
CHATBOTS['Gemini'].models &&
@@ -74,7 +75,8 @@ export const gemini: Chatbot = {
7475
await new Promise((r) => requestAnimationFrame(r))
7576
}
7677
},
77-
set_options: async (options?: string[]) => {
78+
set_options: async (chat) => {
79+
const options = chat.options
7880
if (!options) return
7981
const supported_options = CHATBOTS['Gemini'].supported_options
8082
if (

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/github-copilot.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const github_copilot: Chatbot = {
1919
check_for_element()
2020
})
2121
},
22-
set_model: async (model?: string) => {
22+
set_model: async (chat) => {
23+
const model = chat.model
2324
if (!model) return
2425

2526
const model_selector_button = document.querySelector(

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const grok: Chatbot = {
2020
})
2121
await new Promise((r) => setTimeout(r, 500))
2222
},
23-
set_options: async (options?: string[]) => {
23+
set_options: async (chat) => {
24+
const options = chat.options
2425
if (!options) return
2526
const supported_options = CHATBOTS['Grok'].supported_options
2627
for (const option of options) {
@@ -39,7 +40,8 @@ export const grok: Chatbot = {
3940
}
4041
}
4142
},
42-
set_model: async (model?: string) => {
43+
set_model: async (chat) => {
44+
const model = chat.model
4345
if (!model) return
4446

4547
const model_selector_buttons = document.querySelectorAll(

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/hugging-chat.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const hugging_chat: Chatbot = {
99
wait_until_ready: async () => {
1010
await new Promise((resolve) => setTimeout(resolve, 500))
1111
},
12-
set_model: async (model?: string) => {
12+
set_model: async (chat) => {
13+
const model = chat.model
1314
if (!model) return
1415

1516
const model_picker_button = document.querySelector(

0 commit comments

Comments
 (0)