From 3315c3cac09ffb854e576c4e10ec59c40e1822d5 Mon Sep 17 00:00:00 2001 From: Web4 <137041369+QUBUHUB@users.noreply.github.com> Date: Tue, 25 Feb 2025 10:21:30 -0500 Subject: [PATCH] Create Index.js --- Index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Index.js diff --git a/Index.js b/Index.js new file mode 100644 index 000000000..113fa384a --- /dev/null +++ b/Index.js @@ -0,0 +1,27 @@ +export default { + async fetch(request, env) { + const tasks = []; + + + // prompt - simple completion style input + let simple = { + prompt: 'Tell me a joke about Cloudflare' + }; + let response = await env.AI.run('@cf/meta/llama-3-8b-instruct', simple); + tasks.push({ inputs: simple, response }); + + + // messages - chat style input + let chat = { + messages: [ + { role: 'system', content: 'You are a helpful assistant.' }, + { role: 'user', content: 'Who won the world series in 2020?' } + ] + }; + response = await env.AI.run('@cf/meta/llama-3-8b-instruct', chat); + tasks.push({ inputs: chat, response }); + + + return Response.json(tasks); + } +};