mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 07:10:34 -07:00
Disallow unsafe type assertions (#18688)
This commit is contained in:
committed by
GitHub
parent
bce1caefd0
commit
fd65416a2f
@@ -282,6 +282,7 @@ export class HookTranslatorGenAIv1 extends HookTranslator {
|
||||
parts: textParts,
|
||||
},
|
||||
finishReason:
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
candidate.finishReason as LLMResponse['candidates'][0]['finishReason'],
|
||||
index: candidate.index,
|
||||
safetyRatings: candidate.safetyRatings?.map((rating) => ({
|
||||
@@ -306,6 +307,7 @@ export class HookTranslatorGenAIv1 extends HookTranslator {
|
||||
*/
|
||||
fromHookLLMResponse(hookResponse: LLMResponse): GenerateContentResponse {
|
||||
// Build response object with proper structure
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const response: GenerateContentResponse = {
|
||||
text: hookResponse.text,
|
||||
candidates: hookResponse.candidates.map((candidate) => ({
|
||||
@@ -315,6 +317,7 @@ export class HookTranslatorGenAIv1 extends HookTranslator {
|
||||
text: part,
|
||||
})),
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
finishReason: candidate.finishReason as FinishReason,
|
||||
index: candidate.index,
|
||||
safetyRatings: candidate.safetyRatings,
|
||||
@@ -330,6 +333,7 @@ export class HookTranslatorGenAIv1 extends HookTranslator {
|
||||
*/
|
||||
toHookToolConfig(sdkToolConfig: ToolConfig): HookToolConfig {
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
mode: sdkToolConfig.functionCallingConfig?.mode as HookToolConfig['mode'],
|
||||
allowedFunctionNames:
|
||||
sdkToolConfig.functionCallingConfig?.allowedFunctionNames,
|
||||
@@ -342,7 +346,8 @@ export class HookTranslatorGenAIv1 extends HookTranslator {
|
||||
fromHookToolConfig(hookToolConfig: HookToolConfig): ToolConfig {
|
||||
const functionCallingConfig: FunctionCallingConfig | undefined =
|
||||
hookToolConfig.mode || hookToolConfig.allowedFunctionNames
|
||||
? ({
|
||||
? // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
({
|
||||
mode: hookToolConfig.mode,
|
||||
allowedFunctionNames: hookToolConfig.allowedFunctionNames,
|
||||
} as FunctionCallingConfig)
|
||||
|
||||
Reference in New Issue
Block a user