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.3 KB · 18 lines typescript
Raw Blame History
1// (h) Built-in web_search tool: output items, annotations (url_citation), streaming event names.2import { client, attempt, save } from "./lib";3const out: any[] = [];4for (const model of ["gpt-5.5", "gpt-5.4-mini"]) {5  out.push(await attempt(`web_search:${model}`, async () => {6    const stream = await client.responses.create({ model, tools: [{ type: "web_search" }], include: ["web_search_call.action.sources"],7      input: "In one sentence: what is the current top headline on reuters.com? Cite the source.", max_output_tokens: 200, stream: true } as any);8    const order: string[] = []; let final: any = null;9    for await (const ev of stream as any) { if (!order.includes(ev.type)) order.push(ev.type); if (ev.type === "response.completed" || ev.type === "response.incomplete") final = ev.response; }10    const msg = final.output.find((o: any) => o.type === "message");11    const ws = final.output.find((o: any) => o.type === "web_search_call");12    return { event_order: order, status: final.status, output_types: final.output.map((o: any) => o.type), usage: final.usage,13      web_search_call: ws ? { id: ws.id, status: ws.status, action: ws.action } : null,14      annotations: msg?.content?.[0]?.annotations ?? null, text: (final.output_text ?? "").slice(0, 300), tools_echo: final.tools };15  }));16}17save("09-web-search", out);18