I have an `await` on my call to the worker binding
I have an
await on my call to the worker binding


_headers _redirects files feature and workers.js? _redirects file in same time.

_worker.js file, but it seems that cloudflare is not picking it.nodejs_compat compatibility flag is not active by default nor it will be.
import { Ai } from '@cloudflare/ai'
export async function onRequest(context) {
const ai = new Ai(context.env.AI);
const input = { prompt: "What is the origin of the phrase Hello, World" }
const answer = await ai.run('@cf/meta/llama-2-7b-chat-int8', input);
return Response.json(answer);
}
npm i @cloudflare/aiwrangler pages deployment tail_headers_redirects_redirectsworkers.js
import { Ai } from '@cloudflare/ai'
export async function onRequest(context) {
const ai = new Ai(context.env.AI);
const input = { prompt: "What is the origin of the phrase Hello, World" }
const answer = await ai.run('@cf/meta/llama-2-7b-chat-int8', input);
return Response.json(answer);
}
npm i @cloudflare/ai/**
* POST /api/submit
*/
export async function onRequestPost(context) {
try {
let input = await context.request.formData();
let pretty = JSON.stringify([...input], null, 2);
console.log(input.toString());
console.log("Sending Discord Message");
sendDiscordMessage("Website Contact Form", pretty, "https://discord.com/api/webhooks/1161255461614526525/");
return new Response(pretty, {
headers: {
'Content-Type': 'application/json;charset=utf-8',
},
});
} catch (err) {
return new Response('Error parsing JSON content', { status: 400 });
}
}
async function sendDiscordMessage(name, message, webhookUrl) {
await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'Website Contact Form',
embeds: [{
title: 'New Message',
type: 'rich',
fields: [
{
name: 'Name',
value: name,
},
{
name: 'Message',
value: message,
}
]
}]
}),
});
console.log("Message Sent");
console.log(fetch)
}