phase 5 part 3: mongodb, elasticsearch hybrid search, data-pipeline, nodejs BFF topics with verified examples
This commit is contained in:
1 parent
9eeb10aede
commit
075872e31e
27 files changed
+2405
-52
No files matched your search
@@ -0,0 +1,17 @@
|
||||
// 不自动运行:启动服务 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}`));
|
||||
Reference in new issue
Block a user