mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Bugfix/Gemini Structured Output (#4713)
* fix gemini structured output * update issues templates
This commit is contained in:
+3
-15
@@ -3,8 +3,7 @@ import { VectorStore, VectorStoreRetriever, VectorStoreRetrieverInput } from '@l
|
||||
import { INode, INodeData, INodeParams, INodeOutputsValue } from '../../../src/Interface'
|
||||
import { handleEscapeCharacters } from '../../../src'
|
||||
import { z } from 'zod'
|
||||
import { convertStructuredSchemaToZod, ExtractTool } from '../../sequentialagents/commonUtils'
|
||||
import { ChatGoogleGenerativeAI } from '@langchain/google-genai'
|
||||
import { convertStructuredSchemaToZod } from '../../sequentialagents/commonUtils'
|
||||
|
||||
const queryPrefix = 'query'
|
||||
const defaultPrompt = `Extract keywords from the query: {{${queryPrefix}}}`
|
||||
@@ -126,19 +125,8 @@ class ExtractMetadataRetriever_Retrievers implements INode {
|
||||
try {
|
||||
const structuredOutput = z.object(convertStructuredSchemaToZod(llmStructuredOutput))
|
||||
|
||||
if (llm instanceof ChatGoogleGenerativeAI) {
|
||||
const tool = new ExtractTool({
|
||||
schema: structuredOutput
|
||||
})
|
||||
// @ts-ignore
|
||||
const modelWithTool = llm.bind({
|
||||
tools: [tool]
|
||||
}) as any
|
||||
llm = modelWithTool
|
||||
} else {
|
||||
// @ts-ignore
|
||||
llm = llm.withStructuredOutput(structuredOutput)
|
||||
}
|
||||
// @ts-ignore
|
||||
llm = llm.withStructuredOutput(structuredOutput)
|
||||
} catch (exception) {
|
||||
console.error(exception)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user