Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…mas for the AI Agent
…ut to be able to specify the AI Agent to return a specific Flow Builder content + handle the AI Agent response to fetch this content from Flow Builder with all its followups
f6ee699 to
88a52ee
Compare
Test Results42 tests 42 ✅ 1m 21s ⏱️ Results for commit 88a52ee. |
There was a problem hiding this comment.
I think it would be simpler to declare the ZOD schema within the plugin-ai-agent, just like the other schemas. You’d save yourself all the logic in the plugin-flow-builder when declaring the schema (this is the only one here). You’d also avoid all the logic within the plugin-ai-agent for fetching external schemas and type inference.
There was a problem hiding this comment.
I agree, but doing that you would both plugins would be coupled and I don't think it's a good idea...
Also, doing it the way it is done we allow the bots to add other possible schemas more specific for its use cases, expanding the possibilities of the AI Agents. If we add this new schema in the AI Agent's plugin we will lose this improvement.
As a summary, I would leave it as it is now to expand the possibilities of the AI Agents plugin.
0c3f993 to
bab2e9d
Compare
| private name: string | ||
| private instructions: string | ||
| private tools: Tool<TPlugins, TExtraData>[] | ||
| private externalOutputMessagesSchemas: z.ZodObject<any>[] |
There was a problem hiding this comment.
then should this get typed as z.ZodObject<OutputSchema[]>?
There was a problem hiding this comment.
I don't think so because it won't contain any of the baseMessageSchemas.
…from AI Agent (#3188) ## Description Add a new target attribute in the textWithButtons output schema in the AI Agent plugin and make them reach the render of the FlowButton in Flow Builder plugin so an URL button can open the link within the same window if stated in the AI Agent prompt. ## Context Through the AI Agent prompt there was no way to make a URL button to open the website within the same window as the webchat. ## Testing The pull request has unit tests.
Description
Allow the AI Agent to return custom structured output message types beyond the built-in ones (text, carousel, etc.). This enables the Flow Builder plugin to instruct the AI Agent to respond with a specific Flow Builder content ID, which is then resolved into its full content with all follow-ups.
Context
Currently, the AI Agent can only return a fixed set of message types. There are scenarios where the AI Agent needs to respond by referencing existing Flow Builder content (e.g. a specific node in the flow) instead of generating a free-form response. This PR makes the output schema extensible so that each consumer can inject its own message types.
Approach taken / Explain the design
1. Generic core interfaces (
botonic-core)BaseMessage,OutputMessage,AgenticOutputMessage,RunResult, andInferenceResponsegeneric with anExtratype parameter, so they can carry additional message types while remaining backward-compatible (defaults tonever).outputMessagesSchemastoAiAgentArgsto pass extra Zod schemas to the agent.2. Dynamic output schema (
botonic-plugin-ai-agents)getOutputSchema(externalSchemas)that merges them with any externally provided Zod schemas at runtime.AIAgentBuildernow receives and forwardsoutputMessagesSchemas.3. Flow Builder content message (
botonic-plugin-flow-builder)FlowBuilderContentMessagetype and its correspondingFlowBuilderContentSchemaZod object, representing a message with acontentIdpointing to a Flow Builder node.getContentsByAiAgentto:FlowBuilderContentSchemato the AI Agent plugin.flowBuilderContentmessages.flowBuilderContentmessage by fetching the referenced node from the CMS and returning its full contents.To document / Usage example
To add a custom output message type, define a Zod schema and pass it in
outputMessagesSchemas:The AI Agent will then be able to return messages of that type alongside the built-in ones.
As for the new
FlowBuilderContentSchema, in the AI Agent prompt you could do something like this:"If the user is asking for the status of an order, display the Flow Builder content 'OPEN_WISMO_WEBVIEW'"
This will result in the AI Agent returning as a response the contents of the Flow Builder content ID OPEN_WISMO_WEBVIEW directly.
Testing
The pull request has unit tests.