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%
2.3 KB · 19 lines typescript
Raw Blame History
1// (i) Does Chat Completions still work? Streaming chunk + usage shape; temperature behaviour on GPT-5.x via chat.2import { client, attempt, save } from "./lib";3const out: any[] = [];4out.push(await attempt("chat:gpt-4.1-mini:stream+temperature", async () => {5  const s = await client.chat.completions.create({ model: "gpt-4.1-mini", messages: [{ role: "system", content: "Be terse." }, { role: "user", content: "Say pong." }], temperature: 0.3, max_completion_tokens: 30, stream: true, stream_options: { include_usage: true } });6  let text = "", usage: any = null, finish: any = null, n = 0, first: any = null;7  for await (const c of s) { n++; if (!first) first = c; text += c.choices[0]?.delta?.content ?? ""; if (c.choices[0]?.finish_reason) finish = c.choices[0].finish_reason; if (c.usage) usage = c.usage; }8  return { chunks: n, first_chunk: first, text, finish, usage };9}));10out.push(await attempt("chat:gpt-5.5:temperature", () => client.chat.completions.create({ model: "gpt-5.5", messages: [{ role: "user", content: "Say pong." }], temperature: 0.3, max_completion_tokens: 30 }).then(r => ({ text: r.choices[0].message.content, usage: r.usage }))));11out.push(await attempt("chat:gpt-5.5:reasoning_effort=low+verbosity", () => client.chat.completions.create({ model: "gpt-5.5", messages: [{ role: "developer", content: "Be terse." }, { role: "user", content: "Say pong." }], reasoning_effort: "low", verbosity: "low", max_completion_tokens: 60 } as any).then(r => ({ text: r.choices[0].message.content, usage: r.usage, model: r.model }))));12out.push(await attempt("chat:gpt-6-astra:max_tokens(deprecated param)", () => client.chat.completions.create({ model: "gpt-6-astra", messages: [{ role: "user", content: "Say pong." }], max_tokens: 60 } as any).then(r => ({ text: r.choices[0].message.content, usage: r.usage }))));13out.push(await attempt("chat:o4-mini:stream", async () => {14  const s = await client.chat.completions.create({ model: "o4-mini", messages: [{ role: "user", content: "Say pong." }], max_completion_tokens: 60, stream: true, stream_options: { include_usage: true } });15  let usage: any = null, text = ""; for await (const c of s) { text += c.choices[0]?.delta?.content ?? ""; if (c.usage) usage = c.usage; }16  return { text, usage };17}));18save("10-chat-completions", out);19