1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export default async function server(request: Request): Promise<Response> {
// Parse the request body
let body: { inputs: Record<string, string>, output: string, correct_answer: string };
body = await request.json();
const score = body.output.toLowerCase() === body.correct_answer.toLowerCase() ? 1.0 : 0.0;
const responseBody = { score };
return new Response(JSON.stringify(responseBody), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}