@devries-cameron20 / OCIU-npo Mirror · read-only
Fork 0

Mirrored from https://github.com/Camo67/OCIU-npo.git

Synced Nov 21, 03:37 UTC

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 };