const payload = {
messages: messages.map((msg) => ({
role: msg.role,
content: msg.content,
})),
response_format: {
type: 'json_schema',
schema: {
type: 'object',
properties: {
tournament: {
type: 'string',
enum: possibleTournaments,
},
round: {
type: 'integer',
minimum: 1,
},
flight: {
type: ['integer', 'null'],
minimum: 1,
},
},
required: ['tournament', 'round', 'flight'],
additionalProperties: false,
},
},
}
//console.log(payload)
let response = await env.AI.run("@cf/meta/llama-3-8b-instruct", {
...payload,
});
/// just send the raw response back as json
return new Response(JSON.stringify(response), {
headers: {
'Content-Type': 'application/json',
},
});
const payload = {
messages: messages.map((msg) => ({
role: msg.role,
content: msg.content,
})),
response_format: {
type: 'json_schema',
schema: {
type: 'object',
properties: {
tournament: {
type: 'string',
enum: possibleTournaments,
},
round: {
type: 'integer',
minimum: 1,
},
flight: {
type: ['integer', 'null'],
minimum: 1,
},
},
required: ['tournament', 'round', 'flight'],
additionalProperties: false,
},
},
}
//console.log(payload)
let response = await env.AI.run("@cf/meta/llama-3-8b-instruct", {
...payload,
});
/// just send the raw response back as json
return new Response(JSON.stringify(response), {
headers: {
'Content-Type': 'application/json',
},
});