Hi everyone,
I’m struggling with the Transform node in OpenAI Agent Builder and need help filtering a JSON array using Common Expression Language (CEL).
My Data Structure
I have an output from a previous node (output_parsed) with this structure:
json
{ "items": [ { "title": "Movie Title 1", "platform": "Netflix" }, { "title": "Movie Title 2", "platform": "Prime" }, { "title": "Movie Title 3", "platform": "Disney+" } ]}
What I’m Trying to Do
I want to filter the items array to only include objects where platform is either “Netflix” or “Prime”, using a Transform node.
What I’ve Tried
I’ve tried multiple CEL expressions in the Transform Value field, but all fail with syntax errors:
input.output_parsed.items.filter(x, x.platform == 'Netflix' || x.platform == 'Prime')- Error: “Expecting: one of these possible Token sequences…”
[item for item in input.output_parsed.items if item.platform == 'Netflix']- Error: Same token sequence error
input.output_parsed.items.filter(item, item.platform == 'Netflix')- Error: Still failing
Questions
- Does CEL in Transform nodes support
.filter()macro? - Is there a correct syntax for filtering arrays in Transform expressions?
- Should I use the Code tab instead for array filtering operations?
According to the documentation, CEL supports macros like .all(), but I can’t find examples of .filter() or array filtering for Transform nodes.
Any help would be greatly appreciated! Is filtering arrays even possible with Transform nodes, or do I need to use custom code?
Thanks in advance!