TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1// Probe (e): structured output via response_format json_schema (strict).2import { CHAT_MODELS, raw, save, short } from "./lib.ts";34const response_format = {5 type: "json_schema",6 json_schema: {7 name: "city_info",8 strict: true,9 schema: {10 type: "object",11 properties: { city: { type: "string" }, country: { type: "string" }, population_millions: { type: "number" } },12 required: ["city", "country", "population_millions"],13 additionalProperties: false,14 },15 },16};17const results: Record<string, any> = {};18await Promise.all(19 CHAT_MODELS.map(async (model) => {20 const r = await raw("/chat/completions", {21 method: "POST",22 body: JSON.stringify({ model, messages: [{ role: "user", content: "Give info about Paris." }], response_format, max_completion_tokens: 300 }),23 });24 const b: any = r.body;25 let parsed: any = null;26 try {27 parsed = JSON.parse(b.choices?.[0]?.message?.content ?? "");28 } catch {}29 results[model] = { status: r.status, content: b.choices?.[0]?.message?.content, parsedOk: !!parsed, usage: b.usage, error: r.status !== 200 ? b : undefined };30 console.log(model.padEnd(30), r.status, short(b.choices?.[0]?.message?.content ?? b, 200));31 }),32);33save("04-structured.json", results);34