Skip to content

Commit 3dc2337

Browse files
committed
Refactor apply_reasoning_effort to use named parameters and remove unused path-parser module
1 parent dd347fe commit 3dc2337

16 files changed

Lines changed: 45 additions & 228 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,11 @@ const perform_code_at_cursor = async (params: {
405405
temperature: code_at_cursor_config.temperature
406406
}
407407

408-
apply_reasoning_effort(
408+
apply_reasoning_effort({
409409
body,
410410
provider,
411-
code_at_cursor_config.reasoning_effort
412-
)
411+
reasoning_effort: code_at_cursor_config.reasoning_effort
412+
})
413413

414414
const cursor_listener = vscode.window.onDidChangeTextEditorSelection(() => {
415415
cancel_token_source.cancel('User moved the cursor, cancelling request.')

‎apps/editor/src/commands/generate-commit-message-command/utils/generate-commit-message-with-api.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export const generate_commit_message_with_api = async (params: {
2626
temperature: params.config.temperature
2727
}
2828

29-
apply_reasoning_effort(body, params.provider, params.config.reasoning_effort)
29+
apply_reasoning_effort({
30+
body,
31+
provider: params.provider,
32+
reasoning_effort: params.config.reasoning_effort
33+
})
3034

3135
const cancel_token_source = axios.CancelToken.source()
3236

‎apps/editor/src/commands/search-files-for-context.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const search_files_for_context_command = (
4040
input_box.title = 'Search'
4141
input_box.prompt = 'Enter text to search for.'
4242
input_box.placeholder = 'Search'
43-
input_box.ignoreFocusOut = true
4443
input_box.value = initial_keywords
4544

4645
const close_button = {

‎apps/editor/src/utils/apply-reasoning-effort.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { ToolConfig } from '@/services/model-providers-manager'
22

3-
export const apply_reasoning_effort = (
4-
body: { [key: string]: any },
5-
provider: any,
3+
export const apply_reasoning_effort = (params: {
4+
body: { [key: string]: any }
5+
provider: any
66
reasoning_effort?: ToolConfig['reasoning_effort']
7-
) => {
8-
if (provider.name == 'OpenRouter') {
9-
if (reasoning_effort) {
10-
if (reasoning_effort == 'none') {
11-
body.reasoning = { enabled: false }
7+
}) => {
8+
if (params.provider.name == 'OpenRouter') {
9+
if (params.reasoning_effort) {
10+
if (params.reasoning_effort == 'none') {
11+
params.body.reasoning = { enabled: false }
1212
} else {
13-
body.reasoning = { effort: reasoning_effort }
13+
params.body.reasoning = { effort: params.reasoning_effort }
1414
}
1515
}
16-
} else if (provider.name == 'Google') {
17-
body.extra_body = {
16+
} else if (params.provider.name == 'Google') {
17+
params.body.extra_body = {
1818
google: {
1919
thinking_config: {
20-
thinking_level: reasoning_effort,
20+
thinking_level: params.reasoning_effort,
2121
include_thoughts: true
2222
}
2323
}

‎apps/editor/src/utils/cleanup-api-response/cleanup-api-response.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* Cleans up the API response by iteratively stripping away wrapper markup
3-
* at the beginning and end of the content, without affecting the middle content.
4-
* Used by intelligent update/code completions command.
5-
*/
61
export const cleanup_api_response = (params: { content: string }): string => {
72
let content = params.content.trim()
83
let changed = true
@@ -19,17 +14,12 @@ export const cleanup_api_response = (params: { content: string }): string => {
1914
}
2015
}
2116

22-
// If there is a markdown block surrounded by text, extract it.
23-
// This is more robust than counting ``` occurrences, which can be fooled by
24-
// ``` inside string literals. It also avoids a slow regex.
2517
const first_backticks = content.indexOf('```')
2618
const last_backticks = content.lastIndexOf('```')
2719
if (first_backticks !== -1 && first_backticks < last_backticks) {
2820
const before = content.substring(0, first_backticks).trim()
2921
const after = content.substring(last_backticks + 3).trim()
3022

31-
// If there is text before or after the block, we assume it's a single
32-
// block to be extracted.
3323
if (before || after) {
3424
const end_of_first_line = content.indexOf('\n', first_backticks)
3525
if (end_of_first_line > -1 && end_of_first_line < last_backticks) {

‎apps/editor/src/utils/intelligent-update-utils.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ export const process_file = async (params: {
248248
temperature: params.temperature
249249
}
250250

251-
apply_reasoning_effort(body, params.provider, params.reasoning_effort)
251+
apply_reasoning_effort({
252+
body,
253+
provider: params.provider,
254+
reasoning_effort: params.reasoning_effort
255+
})
252256

253257
const MAX_ATTEMPTS = 3
254258
let attempt = 0

‎apps/editor/src/utils/path-parser/index.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎apps/editor/src/utils/path-parser/path-parser.spec.ts‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎apps/editor/src/utils/path-parser/path-parser.ts‎

Lines changed: 0 additions & 118 deletions
This file was deleted.

‎apps/editor/src/views/panel/backend/message-handlers/handle-code-at-cursor.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,11 @@ export const handle_code_at_cursor = async (
457457
temperature: code_completions_config.temperature
458458
}
459459

460-
apply_reasoning_effort(
460+
apply_reasoning_effort({
461461
body,
462462
provider,
463-
code_completions_config.reasoning_effort
464-
)
463+
reasoning_effort: code_completions_config.reasoning_effort
464+
})
465465

466466
let error_occurred = false
467467

0 commit comments

Comments
 (0)