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%
4.8 KB · 33 lines typescript
Raw Blame History
1// Misc: roles (system vs developer), previous_response_id, store:false + encrypted reasoning, PDF input, prompt cache params, reasoning.context.2import { client, attempt, save, summarizeResponse, tinyPdfBase64 } from "./lib";3const out: any[] = [];4for (const model of ["gpt-5.5", "gpt-4.1-mini"]) {5  out.push(await attempt(`roles:system:${model}`, () => client.responses.create({ model, input: [{ role: "system", content: "Always answer in French." }, { role: "user", content: "Say hello." }], max_output_tokens: 60 } as any).then(summarizeResponse)));6  out.push(await attempt(`roles:developer+instructions:${model}`, () => client.responses.create({ model, instructions: "Always answer in Spanish.", input: [{ role: "developer", content: "Prefix with 'DEV:'." }, { role: "user", content: "Say hello." }], max_output_tokens: 60 } as any).then(r => ({ ...summarizeResponse(r), instructions_echo: r.instructions }))));7}8out.push(await attempt("previous_response_id:gpt-5.4-mini", async () => {9  const r1: any = await client.responses.create({ model: "gpt-5.4-mini", input: "My favourite number is 7. Reply OK.", max_output_tokens: 32 });10  const r2: any = await client.responses.create({ model: "gpt-5.4-mini", previous_response_id: r1.id, input: "What is my favourite number? One word.", max_output_tokens: 32 });11  return { r1: summarizeResponse(r1), r2: { ...summarizeResponse(r2), previous_response_id: r2.previous_response_id } };12}));13out.push(await attempt("previous_response_id with store:false (expected to fail)", async () => {14  const r1: any = await client.responses.create({ model: "gpt-5.4-mini", input: "Reply OK.", max_output_tokens: 16, store: false });15  return client.responses.create({ model: "gpt-5.4-mini", previous_response_id: r1.id, input: "Again.", max_output_tokens: 16 }).then(summarizeResponse);16}));17out.push(await attempt("encrypted_reasoning_roundtrip:gpt-5.5", async () => {18  const r1: any = await client.responses.create({ model: "gpt-5.5", input: "Think briefly, then say OK.", max_output_tokens: 100, store: false, include: ["reasoning.encrypted_content"], reasoning: { effort: "low" } } as any);19  const reasoning = r1.output.filter((o: any) => o.type === "reasoning").map((o: any) => ({ id: o.id, has_encrypted: !!o.encrypted_content, encrypted_len: o.encrypted_content?.length ?? 0, summary_len: o.summary?.length ?? 0 }));20  const r2: any = await client.responses.create({ model: "gpt-5.5", input: [{ role: "user", content: "Think briefly, then say OK." }, ...r1.output, { role: "user", content: "Now say DONE." }], max_output_tokens: 60, store: false, include: ["reasoning.encrypted_content"], reasoning: { effort: "low" } } as any);21  return { r1: summarizeResponse(r1), reasoning_items: reasoning, r2: summarizeResponse(r2) };22}));23out.push(await attempt("pdf_input:gpt-5.4-mini", () => client.responses.create({ model: "gpt-5.4-mini", max_output_tokens: 100, input: [{ role: "user", content: [24  { type: "input_text", text: "What secret number is written in this PDF? Answer with the number only." },25  { type: "input_file", filename: "probe.pdf", file_data: `data:application/pdf;base64,${tinyPdfBase64()}` }] }] } as any).then(summarizeResponse)));26out.push(await attempt("prompt_cache_retention=24h:gpt-5.5", () => client.responses.create({ model: "gpt-5.5", input: "Say OK.", max_output_tokens: 16, prompt_cache_key: "polyllm-probe", prompt_cache_retention: "24h" } as any).then(r => ({ ...summarizeResponse(r), prompt_cache_key: r.prompt_cache_key, prompt_cache_retention: r.prompt_cache_retention }))));27out.push(await attempt("prompt_cache_options.ttl=30m:gpt-5.6-sol", () => client.responses.create({ model: "gpt-5.6-sol", input: "Say OK.", max_output_tokens: 16, prompt_cache_key: "polyllm-probe", prompt_cache_options: { ttl: "30m" } } as any).then(r => ({ ...summarizeResponse(r), prompt_cache_options: r.prompt_cache_options }))));28out.push(await attempt("prompt_cache_retention=24h:gpt-6-astra (docs: deprecated for 6)", () => client.responses.create({ model: "gpt-6-astra", input: "Say OK.", max_output_tokens: 32, prompt_cache_retention: "24h" } as any).then(summarizeResponse)));29out.push(await attempt("reasoning.context=all_turns:gpt-5.6-sol", () => client.responses.create({ model: "gpt-5.6-sol", input: "Say OK.", max_output_tokens: 32, reasoning: { effort: "low", context: "all_turns" } } as any).then(summarizeResponse)));30out.push(await attempt("service_tier=flex:gpt-5.4-mini", () => client.responses.create({ model: "gpt-5.4-mini", input: "Say OK.", max_output_tokens: 32, service_tier: "flex" } as any).then(summarizeResponse)));31out.push(await attempt("input_audio in Responses (expect reject):gpt-5.5", () => client.responses.create({ model: "gpt-5.5", max_output_tokens: 16, input: [{ role: "user", content: [{ type: "input_audio", input_audio: { data: "UklGRg==", format: "wav" } }] }] } as any).then(summarizeResponse)));32save("11-misc", out);33