fix enum type tools for gemini

pull/2766/head
Henry 2024-07-06 00:39:01 +01:00
parent 90558ca688
commit fbd205e675
2 changed files with 8 additions and 3 deletions

View File

@ -552,6 +552,13 @@ function zodToGeminiParameters(zodObj: any) {
const jsonSchema: any = zodToJsonSchema(zodObj)
// eslint-disable-next-line unused-imports/no-unused-vars
const { $schema, additionalProperties, ...rest } = jsonSchema
if (rest.properties) {
Object.keys(rest.properties).forEach((key) => {
if (rest.properties[key].enum?.length) {
rest.properties[key] = { type: 'string', format: 'enum', enum: rest.properties[key].enum }
}
})
}
return rest
}

View File

@ -273,10 +273,8 @@ class Supervisor_MultiAgents implements INode {
* So we have to place the system + human prompt at last
*/
let prompt = ChatPromptTemplate.fromMessages([
['human', systemPrompt],
['ai', ''],
['system', systemPrompt],
new MessagesPlaceholder('messages'),
['ai', ''],
['human', userPrompt]
])