Bugfix/Enum type tools for gemini (#2766)

fix enum type tools for gemini
This commit is contained in:
Henry Heng 2024-07-09 00:25:18 +01:00 committed by GitHub
parent 90558ca688
commit 3cbbd59242
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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]
])