Test driving PayLoad in Cloudflare Workers/Pages and unable to use this AI plugin for Payload

The plugin in question is this: https://www.npmjs.com/package/@ai-stack/payloadcms It allows me to have prompts to the AI model which utilize other fields in my collection. So say, a prompt like:
Check out the linked article in "{{ article_link }}" and craft compelling content for the complaint email of subject "{{ title }}" targeting critique of such and such...
Check out the linked article in "{{ article_link }}" and craft compelling content for the complaint email of subject "{{ title }}" targeting critique of such and such...
When I run with the local next.js environment, I am able to use the AI features to populate content, however in the deployments on workers+pages, it errors with:
Failed to generate: {"error":"Code generation from strings disallowed for this context"}
Failed to generate: {"error":"Code generation from strings disallowed for this context"}
I am running with debugging true but the the logs in the worker aren't giving much away, and I can't repro the issue locally. At first, I thought it was the handlebars in the prompt that the workers environment is somewhat detecting as hostile, but removing them and just having a static prompt doesn't prevent the issue. I looked at the codebase for the plugin, but I can't detect any evals. The AI execution is remote with models from OpenAI and Anthropic, so not sure what is it detecting as local code generation.
1 Reply
sup filistine
sup filistineOP2mo ago
Yeah, I realized this later. So is this a security mechanism in workers, and that any kind of templating is banned? Mustache works, so there is hope, https://community.cloudflare.com/t/use-js-templating-engine-with-workers-pages-functions-e-g-nunjucks/432850

Did you find this page helpful?