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.6 KB · 17 lines typescript
Raw Blame History
1// Web search retry: non-reasoning gpt-4.1-mini + gpt-5.5 at low effort; read message content + annotations directly.2import { client, attempt, save } from "./lib";3const out: any[] = [];4for (const [model, extra] of [["gpt-4.1-mini", {}], ["gpt-5.5", { reasoning: { effort: "low" } }]] as [string, any][]) {5  out.push(await attempt(`web_search:${model}`, async () => {6    const stream = await client.responses.create({ model, tools: [{ type: "web_search", search_context_size: "low" }], ...extra,7      input: "Who won the most recent FIFA World Cup? Answer in one sentence with a citation.", max_output_tokens: 200, stream: true } as any);8    const order: string[] = []; let final: any = null; const annEvents: any[] = [];9    for await (const ev of stream as any) { if (!order.includes(ev.type)) order.push(ev.type); if (ev.type === "response.output_text.annotation.added") annEvents.push(ev); if (/^response\.(completed|incomplete|failed)$/.test(ev.type)) final = ev.response; }10    const msg = final.output.find((o: any) => o.type === "message");11    return { event_order: order, status: final.status, incomplete: final.incomplete_details, output_types: final.output.map((o: any) => o.type), usage: final.usage,12      web_search_calls: final.output.filter((o: any) => o.type === "web_search_call").map((w: any) => ({ id: w.id, status: w.status, action: w.action })),13      message_content: msg?.content?.map((c: any) => ({ type: c.type, text: c.text?.slice(0, 300), annotations: c.annotations })) ?? null, annotation_events: annEvents.slice(0, 2) };14  }));15}16save("09b-web-search-retry", out);17