Mirrored from https://github.com/Camo67/OCIU-npo.git
Synced Nov 21, 03:37 UTC
Create workers.js
Cameron “Camo” De Vries committed
Oct 8, 2025 at 08:50 UTC
7e8eccf6dec9f43ebfd96a302acb6c6039ca3cca
1 file changed
+27
workers.js
new
+27
@@ -0,0 +1,27 @@
1
+export default {
2
+ async fetch(request, env) {
3
+ const tasks = [];
4
+
5
+
6
+ // prompt - simple completion style input
7
+ let simple = {
8
+ prompt: 'Tell me a joke about Cloudflare'
9
+ };
10
+ let response = await env.AI.run('@cf/meta/llama-3-8b-instruct', simple);
11
+ tasks.push({ inputs: simple, response });
12
+
13
+
14
+ // messages - chat style input
15
+ let chat = {
16
+ messages: [
17
+ { role: 'system', content: 'You are a helpful assistant.' },
18
+ { role: 'user', content: 'Who won the world series in 2020?' }
19
+ ]
20
+ };
21
+ response = await env.AI.run('@cf/meta/llama-3-8b-instruct', chat);
22
+ tasks.push({ inputs: chat, response });
23
+
24
+
25
+ return Response.json(tasks);
26
+ }
27
+};