Flowise
Flowise copied to clipboard
feat: Add structured JSON output support to Agent Node
- Add agentStructuredOutput input parameter matching LLM Node structure
- Implement configureStructuredOutput method to convert schema to Zod
- Add createZodSchemaFromJSON helper for complex JSON schemas
- Configure structured output before binding tools (required order)
- Disable streaming when structured output is enabled
- Extract structured fields in prepareOutputObject method
- Resolves issue #5256
Summary of Changes
Hello @aibysid, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a significant enhancement to the Agent Node by adding robust support for structured JSON output. Users can now define a desired JSON schema for the agent's responses, which is then converted into a Zod schema for validation and enforcement. This feature provides greater control over the format of agent outputs, improving integration with downstream systems and ensuring predictable data structures.
Highlights
- Structured Output Input: Added 'agentStructuredOutput' parameter to the Agent Node for defining JSON output schemas.
- Zod Schema Conversion: Implemented 'configureStructuredOutput' to convert user-defined schemas into Zod schemas.
- Complex JSON Schema Support: Introduced 'createZodSchemaFromJSON' helper for handling intricate nested JSON schemas.
- Execution Order: Ensured structured output configuration occurs before tool binding.
- Streaming Disabled: Streaming is automatically disabled when structured output is active.
- Output Extraction: Structured fields are now extracted and included in the final output object.
- Issue Resolution: Addresses and resolves issue #5256.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
I dont think it is working:
I also dont think we can reuse the same logic as LLM node, because we cant have structured output and tools at the same time. If we want agent to have structured output, we probably have to do it in 2 stages:
- get the output from agent
- call LLM again to output structured data from the answer following the specified schema
@HenryHengZJ agreed on the two stage part , will try to raise a new PR with this approach.
@aibysid I've modified it now: