ship 1.4.48:Arcrun@466a59c5616f
This commit is contained in:
@@ -3324,7 +3324,7 @@ var init_kbdb_proxy = __esm({
|
||||
const { base, headers } = kbdbBase(c.env);
|
||||
const params = new URLSearchParams();
|
||||
params.set("owner_id", owner);
|
||||
for (const k of ["entry_type", "parent_id", "page_name", "source", "library", "limit", "offset"]) {
|
||||
for (const k of ["entry_type", "parent_id", "page_name", "source", "library", "exclude_kind", "limit", "offset"]) {
|
||||
const v = c.req.query(k);
|
||||
if (v) params.set(k, v);
|
||||
}
|
||||
@@ -3374,6 +3374,42 @@ var init_kbdb_proxy = __esm({
|
||||
return c.json({ success: false, error: `KBDB \u4E0D\u53EF\u9054\uFF08${base}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}` }, 502);
|
||||
}
|
||||
});
|
||||
kbdbProxyRouter.put("/kbdb/map/:library/narrative", async (c) => {
|
||||
if (!tenant(c)) return c.json(NEED_KEY, 401);
|
||||
const body = await c.req.json().catch(() => null);
|
||||
const narrative = typeof body?.narrative === "string" ? body.narrative : "";
|
||||
if (!narrative.trim()) return c.json({ error: "narrative \u5FC5\u586B\uFF08\u4E0D\u5F97\u7A7A\u767D\uFF09" }, 400);
|
||||
const owner = (typeof body?.owner_id === "string" ? body.owner_id : c.req.query("owner_id")) || void 0;
|
||||
const { base, headers } = kbdbBase(c.env);
|
||||
try {
|
||||
const res = await fetch(`${base}/map/${encodeURIComponent(c.req.param("library"))}/narrative`, {
|
||||
method: "PUT",
|
||||
headers,
|
||||
body: JSON.stringify({ narrative, ...owner ? { owner_id: owner } : {} })
|
||||
});
|
||||
return new Response(res.body, { status: res.status, headers: { "Content-Type": "application/json" } });
|
||||
} catch (e) {
|
||||
return c.json({ success: false, error: `KBDB \u4E0D\u53EF\u9054\uFF08${base}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}` }, 502);
|
||||
}
|
||||
});
|
||||
kbdbProxyRouter.post("/kbdb/map/recompute", async (c) => {
|
||||
if (!tenant(c)) return c.json(NEED_KEY, 401);
|
||||
const body = await c.req.json().catch(() => ({}));
|
||||
const library = (typeof body.library === "string" ? body.library : c.req.query("library")) || "";
|
||||
if (!library.trim()) return c.json({ error: "library \u5FC5\u586B" }, 400);
|
||||
const owner = (typeof body.owner_id === "string" ? body.owner_id : c.req.query("owner_id")) || void 0;
|
||||
const { base, headers } = kbdbBase(c.env);
|
||||
try {
|
||||
const res = await fetch(`${base}/map/recompute`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({ ...body, library, ...owner ? { owner_id: owner } : {} })
|
||||
});
|
||||
return new Response(res.body, { status: res.status, headers: { "Content-Type": "application/json" } });
|
||||
} catch (e) {
|
||||
return c.json({ success: false, error: `KBDB \u4E0D\u53EF\u9054\uFF08${base}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}` }, 502);
|
||||
}
|
||||
});
|
||||
kbdbProxyRouter.patch("/kbdb/entries/:id", async (c) => {
|
||||
if (!tenant(c)) return c.json(NEED_KEY, 401);
|
||||
const body = await c.req.json().catch(() => ({}));
|
||||
@@ -15323,10 +15359,12 @@ portalDataRouter.get(
|
||||
}
|
||||
const inner = unwrapWorkflowData(result.data, "answer");
|
||||
const rawSources = Array.isArray(inner.sources) ? inner.sources : [];
|
||||
const retrieval = inner.retrieval;
|
||||
return c.json({
|
||||
answer: typeof inner.answer === "string" ? inner.answer : "",
|
||||
sources: dedupeSourcesByPage(rawSources),
|
||||
graph_facts: inner.graph_facts ?? null
|
||||
graph_facts: inner.graph_facts ?? null,
|
||||
retrieval: retrieval && typeof retrieval === "object" ? retrieval : null
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user