refactor(core): Migrate next speaker check to use BaseLlmClient (#8424)

This commit is contained in:
Abhi
2025-09-15 00:15:18 -04:00
committed by GitHub
parent ceed1cfd1c
commit 90f8bf9dfe
4 changed files with 74 additions and 40 deletions
@@ -6,7 +6,7 @@
import type { Content } from '@google/genai';
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
import type { GeminiClient } from '../core/client.js';
import type { BaseLlmClient } from '../core/baseLlmClient.js';
import type { GeminiChat } from '../core/geminiChat.js';
import { isFunctionResponse } from './messageInspectors.js';
@@ -41,8 +41,9 @@ export interface NextSpeakerResponse {
export async function checkNextSpeaker(
chat: GeminiChat,
geminiClient: GeminiClient,
baseLlmClient: BaseLlmClient,
abortSignal: AbortSignal,
promptId: string,
): Promise<NextSpeakerResponse | null> {
// We need to capture the curated history because there are many moments when the model will return invalid turns
// that when passed back up to the endpoint will break subsequent calls. An example of this is when the model decides
@@ -108,12 +109,13 @@ export async function checkNextSpeaker(
];
try {
const parsedResponse = (await geminiClient.generateJson(
const parsedResponse = (await baseLlmClient.generateJson({
contents,
RESPONSE_SCHEMA,
schema: RESPONSE_SCHEMA,
model: DEFAULT_GEMINI_FLASH_MODEL,
abortSignal,
DEFAULT_GEMINI_FLASH_MODEL,
)) as unknown as NextSpeakerResponse;
promptId,
})) as unknown as NextSpeakerResponse;
if (
parsedResponse &&