// 不自动运行:启动服务 node server.ts,然后 curl -N -X POST localhost:3000/chat -H 'content-type: application/json' -d '{"question":"退货"}' import { createApp } from "./app.ts"; async function* fakeLLM(q: string, signal: AbortSignal) { for (const t of ["关于", `“${q}”`, ":", "签收 7 天内", "可以申请退货。"]) { if (signal.aborted) return; await new Promise((r) => setTimeout(r, 200)); yield t; } } const app = createApp({ askLLM: fakeLLM, findOrder: async (id) => (id === "A001" ? { id, status: "paid" } : null), }); const port = Number(process.env.PORT ?? 3000); app.listen(port, () => console.log(`listening on http://127.0.0.1:${port}`));