SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
888 B · 13 lines typescript
Raw Blame History
1// (e) Structured output via text.format json_schema strict.2import { client, attempt, save, PROBE_MODELS, summarizeResponse } from "./lib";3const format: any = { type: "json_schema", name: "person", strict: true, schema: { type: "object", properties: { name: { type: "string" }, age: { type: "integer" }, city: { type: ["string", "null"] } }, required: ["name", "age", "city"], additionalProperties: false } };4const out: any[] = [];5for (const model of PROBE_MODELS) {6  out.push(await attempt(`structured:${model}`, async () => {7    const r: any = await client.responses.create({ model, input: "Marie Curie, 66, lived in Paris. Extract.", text: { format }, max_output_tokens: 200 } as any);8    let parsed: any = null; try { parsed = JSON.parse(r.output_text); } catch { }9    return { ...summarizeResponse(r), parsed, text_format_echo: r.text };10  }));11}12save("06-structured", out);13