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%
1.7 KB · 20 lines typescript
Raw Blame History
1// (e) JSON mode with thinking on and off, per model; plus json_object without the word "json" in the prompt.2import { raw, MODELS, save } from "./lib.ts";34const out: Record<string, unknown> = {};5for (const model of MODELS) {6  for (const thinking of ["enabled", "disabled"] as const) {7    const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model, thinking: { type: thinking }, response_format: { type: "json_object" }, max_tokens: 200, messages: [8      { role: "system", content: "Extract the person. Output json only, format: {\"name\": string, \"age\": number}" },9      { role: "user", content: "Marie is 31 years old." } ] }) });10    const b: any = r.body;11    let parsed: unknown = null; try { parsed = JSON.parse(b.choices?.[0]?.message?.content ?? ""); } catch {}12    out[`${model}|thinking=${thinking}`] = { status: r.status, content: b.choices?.[0]?.message?.content, parsed, reasoning_len: b.choices?.[0]?.message?.reasoning_content?.length ?? null, finish: b.choices?.[0]?.finish_reason, usage: b.usage, error: r.status !== 200 ? b : undefined };13    console.log(model, thinking, r.status, JSON.stringify(b.choices?.[0]?.message?.content ?? b).slice(0, 200), "valid", parsed !== null);14  }15}16const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-flash", thinking: { type: "disabled" }, response_format: { type: "json_object" }, max_tokens: 100, messages: [{ role: "user", content: "Marie is 31 years old. Give her name and age." }] }) });17out["no-json-word"] = { status: r.status, body: r.body };18console.log("no json word in prompt →", r.status, JSON.stringify(r.body).slice(0, 300));19save("04-json.json", out);20