Bugfix/Gemini Structured Output (#4713)

* fix gemini structured output

* update issues templates
This commit is contained in:
Henry Heng
2025-06-23 19:10:41 +01:00
committed by GitHub
parent f50a817bf4
commit 2e42dfb635
10 changed files with 756 additions and 790 deletions
+3 -14
View File
@@ -71,24 +71,13 @@ export const generateFollowUpPrompts = async (
return structuredResponse
}
case FollowUpPromptProvider.GOOGLE_GENAI: {
const llm = new ChatGoogleGenerativeAI({
const model = new ChatGoogleGenerativeAI({
apiKey: credentialData.googleGenerativeAPIKey,
model: providerConfig.modelName,
temperature: parseFloat(`${providerConfig.temperature}`)
})
// use structured output parser because withStructuredOutput is not working
const parser = StructuredOutputParser.fromZodSchema(FollowUpPromptType)
const formatInstructions = parser.getFormatInstructions()
const prompt = PromptTemplate.fromTemplate(`
${providerConfig.prompt}
{format_instructions}
`)
const chain = prompt.pipe(llm).pipe(parser)
const structuredResponse = await chain.invoke({
history: apiMessageContent,
format_instructions: formatInstructions
})
const structuredLLM = model.withStructuredOutput(FollowUpPromptType)
const structuredResponse = await structuredLLM.invoke(followUpPromptsPrompt)
return structuredResponse
}
case FollowUpPromptProvider.MISTRALAI: {