Skip to content

Commit 3cbbd59

Browse files
authored
Bugfix/Enum type tools for gemini (#2766)
fix enum type tools for gemini
1 parent 90558ca commit 3cbbd59

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,13 @@ function zodToGeminiParameters(zodObj: any) {
552552
const jsonSchema: any = zodToJsonSchema(zodObj)
553553
// eslint-disable-next-line unused-imports/no-unused-vars
554554
const { $schema, additionalProperties, ...rest } = jsonSchema
555+
if (rest.properties) {
556+
Object.keys(rest.properties).forEach((key) => {
557+
if (rest.properties[key].enum?.length) {
558+
rest.properties[key] = { type: 'string', format: 'enum', enum: rest.properties[key].enum }
559+
}
560+
})
561+
}
555562
return rest
556563
}
557564

packages/components/nodes/multiagents/Supervisor/Supervisor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,8 @@ class Supervisor_MultiAgents implements INode {
273273
* So we have to place the system + human prompt at last
274274
*/
275275
let prompt = ChatPromptTemplate.fromMessages([
276-
['human', systemPrompt],
277-
['ai', ''],
276+
['system', systemPrompt],
278277
new MessagesPlaceholder('messages'),
279-
['ai', ''],
280278
['human', userPrompt]
281279
])
282280

0 commit comments

Comments
 (0)