diff options
| author | Wanlin Du <[email protected]> | 2025-08-11 16:04:58 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-11 23:04:58 +0000 |
| commit | f52d073dfbfa4d5091a74bf33ac1c66e51265247 (patch) | |
| tree | 583bf7acb989f55110e0b869bb2dbad0ca842770 /packages/core/src/utils | |
| parent | c7fd4c4a962d6e790214e6a0a9cd9b029b85f4e4 (diff) | |
chore: migrate from responseSchema to use responseJsonSchema. (#4814)
Diffstat (limited to 'packages/core/src/utils')
| -rw-r--r-- | packages/core/src/utils/editCorrector.ts | 31 | ||||
| -rw-r--r-- | packages/core/src/utils/nextSpeakerChecker.ts | 10 |
2 files changed, 18 insertions, 23 deletions
diff --git a/packages/core/src/utils/editCorrector.ts b/packages/core/src/utils/editCorrector.ts index 0ef8d4fe..faa52b51 100644 --- a/packages/core/src/utils/editCorrector.ts +++ b/packages/core/src/utils/editCorrector.ts @@ -4,12 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { - Content, - GenerateContentConfig, - SchemaUnion, - Type, -} from '@google/genai'; +import { Content, GenerateContentConfig } from '@google/genai'; import { GeminiClient } from '../core/client.js'; import { EditToolParams, EditTool } from '../tools/edit.js'; import { WriteFileTool } from '../tools/write-file.js'; @@ -364,11 +359,11 @@ export async function ensureCorrectFileContent( } // Define the expected JSON schema for the LLM response for old_string correction -const OLD_STRING_CORRECTION_SCHEMA: SchemaUnion = { - type: Type.OBJECT, +const OLD_STRING_CORRECTION_SCHEMA: Record<string, unknown> = { + type: 'object', properties: { corrected_target_snippet: { - type: Type.STRING, + type: 'string', description: 'The corrected version of the target snippet that exactly and uniquely matches a segment within the provided file content.', }, @@ -438,11 +433,11 @@ Return ONLY the corrected target snippet in the specified JSON format with the k } // Define the expected JSON schema for the new_string correction LLM response -const NEW_STRING_CORRECTION_SCHEMA: SchemaUnion = { - type: Type.OBJECT, +const NEW_STRING_CORRECTION_SCHEMA: Record<string, unknown> = { + type: 'object', properties: { corrected_new_string: { - type: Type.STRING, + type: 'string', description: 'The original_new_string adjusted to be a suitable replacement for the corrected_old_string, while maintaining the original intent of the change.', }, @@ -521,11 +516,11 @@ Return ONLY the corrected string in the specified JSON format with the key 'corr } } -const CORRECT_NEW_STRING_ESCAPING_SCHEMA: SchemaUnion = { - type: Type.OBJECT, +const CORRECT_NEW_STRING_ESCAPING_SCHEMA: Record<string, unknown> = { + type: 'object', properties: { corrected_new_string_escaping: { - type: Type.STRING, + type: 'string', description: 'The new_string with corrected escaping, ensuring it is a proper replacement for the old_string, especially considering potential over-escaping issues from previous LLM generations.', }, @@ -593,11 +588,11 @@ Return ONLY the corrected string in the specified JSON format with the key 'corr } } -const CORRECT_STRING_ESCAPING_SCHEMA: SchemaUnion = { - type: Type.OBJECT, +const CORRECT_STRING_ESCAPING_SCHEMA: Record<string, unknown> = { + type: 'object', properties: { corrected_string_escaping: { - type: Type.STRING, + type: 'string', description: 'The string with corrected escaping, ensuring it is valid, specially considering potential over-escaping issues from previous LLM generations.', }, diff --git a/packages/core/src/utils/nextSpeakerChecker.ts b/packages/core/src/utils/nextSpeakerChecker.ts index 8497db61..4ae8f437 100644 --- a/packages/core/src/utils/nextSpeakerChecker.ts +++ b/packages/core/src/utils/nextSpeakerChecker.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { Content, SchemaUnion, Type } from '@google/genai'; +import { Content } from '@google/genai'; import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js'; import { GeminiClient } from '../core/client.js'; import { GeminiChat } from '../core/geminiChat.js'; @@ -16,16 +16,16 @@ const CHECK_PROMPT = `Analyze *only* the content and structure of your immediate 2. **Question to User:** If your last response ends with a direct question specifically addressed *to the user*, then the **'user'** should speak next. 3. **Waiting for User:** If your last response completed a thought, statement, or task *and* does not meet the criteria for Rule 1 (Model Continues) or Rule 2 (Question to User), it implies a pause expecting user input or reaction. In this case, the **'user'** should speak next.`; -const RESPONSE_SCHEMA: SchemaUnion = { - type: Type.OBJECT, +const RESPONSE_SCHEMA: Record<string, unknown> = { + type: 'object', properties: { reasoning: { - type: Type.STRING, + type: 'string', description: "Brief explanation justifying the 'next_speaker' choice based *strictly* on the applicable rule and the content/structure of the preceding turn.", }, next_speaker: { - type: Type.STRING, + type: 'string', enum: ['user', 'model'], description: 'Who should speak next based *only* on the preceding turn and the decision rules', |
