@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +23 -22
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +36 -7
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/cdn/27NEUQN3.js +2 -0
- package/dist/cdn/2NMR43NW.js +2 -0
- package/dist/cdn/3AXQTBIA.js +134 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4I4MCV7V.js +71 -0
- package/dist/cdn/4RZPOYZ7.js +9 -0
- package/dist/cdn/5SBLS4NW.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
- package/dist/cdn/6LZ6GOHF.js +56 -0
- package/dist/cdn/7IFCBXV7.js +2 -0
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/AFLQZIKS.js +180 -0
- package/dist/cdn/AMVOJNWN.js +2 -0
- package/dist/cdn/C7E7MJSR.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/CIW3QMKV.js +2 -0
- package/dist/cdn/CJIV4KJZ.js +179 -0
- package/dist/cdn/CVHJMR5X.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
- package/dist/cdn/E7TMP4YV.js +3 -0
- package/dist/cdn/EBRNMPPO.js +48 -0
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/HBYZSLEZ.js +22 -0
- package/dist/cdn/HOCTVCHH.js +2 -0
- package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
- package/dist/cdn/I64KIZG3.js +2 -0
- package/dist/cdn/IB4WTK74.js +2 -0
- package/dist/cdn/IC5P5NYY.js +2 -0
- package/dist/cdn/IGZWQJW7.js +3 -0
- package/dist/cdn/IKEF7ZHH.js +181 -0
- package/dist/cdn/IXAKT6L3.js +2 -0
- package/dist/cdn/JEIMRNYM.js +2 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/KRE4U7V7.js +2 -0
- package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
- package/dist/cdn/L77BTGXY.js +2 -0
- package/dist/cdn/LEPJUN3X.js +22 -0
- package/dist/cdn/LODKJRS4.js +2 -0
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/NOJYPREL.js +3 -0
- package/dist/cdn/NXKKG5TK.js +2 -0
- package/dist/cdn/O3F47IO5.js +2 -0
- package/dist/cdn/O7TGCM5P.js +6 -0
- package/dist/cdn/PBTINZTK.js +65 -0
- package/dist/cdn/PKHQW7QU.js +18 -0
- package/dist/cdn/PSWI3MFB.js +2 -0
- package/dist/cdn/Q73PK7Q7.js +2 -0
- package/dist/cdn/Q7TL5Q5N.js +2 -0
- package/dist/cdn/QSA4T3BU.js +2 -0
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/RX45PCYB.js +9 -0
- package/dist/cdn/S27EJSLC.js +14 -0
- package/dist/cdn/SMADRJ67.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/TSEQVE2H.js +36 -0
- package/dist/cdn/VKU4WAQV.js +2 -0
- package/dist/cdn/W2IHPJ54.js +34 -0
- package/dist/cdn/W2JAKE2M.js +2 -0
- package/dist/cdn/WAVKMZA6.js +2 -0
- package/dist/cdn/WDE3HN7K.js +2 -0
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/WNS5ZUF5.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
- package/dist/cdn/XVQJBUMY.js +2 -0
- package/dist/cdn/YJ3QQXF6.js +2 -0
- package/dist/cdn/YRBANNQ5.js +2 -0
- package/dist/cdn/YYY7HKYX.js +2 -0
- package/dist/cdn/ZEYIBYSF.js +66 -0
- package/dist/cdn/ZMSJQB65.js +99 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +1794 -1597
- package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/converterUtils.js +39 -32
- package/dist/chunks/dataExplorationGraph.js +139 -113
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +231 -191
- package/dist/chunks/helpGraph.js +17 -13
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +24 -20
- package/dist/chunks/navigationGraph.js +33 -28
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +267 -226
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +12 -9
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +385 -152
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
- package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/loader.js +7 -6
- package/dist/types/lumina.d.ts +11 -5
- package/dist/types/preact.d.ts +12 -5
- package/dist/types/react.d.ts +13 -5
- package/dist/types/stencil.d.ts +11 -5
- package/dist/utils/index.d.ts +85 -42
- package/dist/utils/index.js +54 -49
- package/package.json +8 -7
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FHVXO2WG.js +0 -166
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GSEPHN3A.js +0 -106
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JY6LLOUJ.js +0 -22
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MDVYQQUG.js +0 -14
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/ON2V5XI2.js +0 -3
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/S6W6HV4T.js +0 -36
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V2P4AIGG.js +0 -2
- package/dist/cdn/V5YEZSRY.js +0 -16
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YY2SBO3V.js +0 -2
|
@@ -36,68 +36,74 @@ function x(e) {
|
|
|
36
36
|
return null;
|
|
37
37
|
for (let r = A(e, 0); r !== -1; r = A(e, r + 1)) {
|
|
38
38
|
let a = 0, c = 0;
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
39
|
+
for (let n = r; n < e.length; n++) {
|
|
40
|
+
const l = e[n];
|
|
41
|
+
if (l === "{" ? a++ : l === "}" ? a-- : l === "[" ? c++ : l === "]" && c--, a < 0 || c < 0)
|
|
42
42
|
break;
|
|
43
|
-
if (a === 0 && c === 0 &&
|
|
44
|
-
return e.slice(r,
|
|
43
|
+
if (a === 0 && c === 0 && n > r)
|
|
44
|
+
return e.slice(r, n + 1);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function O(e) {
|
|
50
50
|
if (!e)
|
|
51
51
|
return "";
|
|
52
52
|
let t = e;
|
|
53
53
|
const r = x(e);
|
|
54
54
|
if (r)
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
56
|
+
const c = JSON.parse(r), l = `
|
|
57
57
|
|
|
58
58
|
\`\`\`json
|
|
59
|
-
${JSON.stringify(
|
|
59
|
+
${JSON.stringify(c, null, 2)}
|
|
60
60
|
\`\`\`
|
|
61
61
|
|
|
62
62
|
`;
|
|
63
|
-
t = e.replace(r,
|
|
63
|
+
t = e.replace(r, l);
|
|
64
64
|
} catch {
|
|
65
65
|
}
|
|
66
|
-
const a =
|
|
67
|
-
return
|
|
66
|
+
const a = E(t);
|
|
67
|
+
return q(a);
|
|
68
68
|
}
|
|
69
69
|
function q(e) {
|
|
70
|
-
|
|
70
|
+
if (!e)
|
|
71
|
+
return "";
|
|
72
|
+
const t = M(e);
|
|
73
|
+
return T(t);
|
|
71
74
|
}
|
|
72
75
|
function E(e) {
|
|
76
|
+
return e ? S.parse(e, { async: !1 }) : "";
|
|
77
|
+
}
|
|
78
|
+
function M(e) {
|
|
73
79
|
if (!e || typeof DOMParser > "u")
|
|
74
80
|
return e;
|
|
75
81
|
try {
|
|
76
82
|
const t = new DOMParser().parseFromString(e, "text/html");
|
|
77
83
|
return Array.from(t.querySelectorAll("table")).forEach((a, c) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
const d = Array.from(
|
|
83
|
-
for (const
|
|
84
|
+
const n = t.createElement("calcite-table");
|
|
85
|
+
n.setAttribute("caption", `Table ${c + 1}`), n.setAttribute("striped", "true");
|
|
86
|
+
const l = a.querySelector("thead");
|
|
87
|
+
if (l) {
|
|
88
|
+
const d = Array.from(l.querySelectorAll("tr"));
|
|
89
|
+
for (const u of d) {
|
|
84
90
|
const o = t.createElement("calcite-table-row");
|
|
85
91
|
o.setAttribute("slot", "table-header");
|
|
86
|
-
const
|
|
87
|
-
for (const
|
|
88
|
-
const s = (
|
|
92
|
+
const f = Array.from(u.querySelectorAll("th, td"));
|
|
93
|
+
for (const h of f) {
|
|
94
|
+
const s = (h.textContent ?? "").trim(), i = t.createElement("calcite-table-header");
|
|
89
95
|
i.setAttribute("heading", s), o.appendChild(i);
|
|
90
96
|
}
|
|
91
|
-
|
|
97
|
+
n.appendChild(o);
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
|
-
const
|
|
95
|
-
(
|
|
96
|
-
const o = t.createElement("calcite-table-row"),
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
for (const s of
|
|
100
|
-
if (
|
|
100
|
+
const b = a.querySelector("tbody");
|
|
101
|
+
(b ? Array.from(b.querySelectorAll("tr")) : Array.from(a.querySelectorAll("tr")).filter((d) => !l?.contains(d))).forEach((d, u) => {
|
|
102
|
+
const o = t.createElement("calcite-table-row"), f = !l && u === 0 && d.querySelectorAll("th").length > 0;
|
|
103
|
+
f && o.setAttribute("slot", "table-header");
|
|
104
|
+
const h = Array.from(d.querySelectorAll("th, td"));
|
|
105
|
+
for (const s of h) {
|
|
106
|
+
if (f && s.localName === "th") {
|
|
101
107
|
const w = (s.textContent ?? "").trim(), y = t.createElement("calcite-table-header");
|
|
102
108
|
y.setAttribute("heading", w), o.appendChild(y);
|
|
103
109
|
return;
|
|
@@ -105,13 +111,14 @@ function E(e) {
|
|
|
105
111
|
const i = t.createElement("calcite-table-cell"), p = s.getAttribute("colspan"), m = s.getAttribute("rowspan");
|
|
106
112
|
p && i.setAttribute("colspan", p), m && i.setAttribute("rowspan", m), i.innerHTML = s.innerHTML, o.appendChild(i);
|
|
107
113
|
}
|
|
108
|
-
|
|
109
|
-
}), a.replaceWith(
|
|
114
|
+
n.appendChild(o);
|
|
115
|
+
}), a.replaceWith(n);
|
|
110
116
|
}), t.body.innerHTML;
|
|
111
117
|
} catch {
|
|
112
118
|
return e;
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
121
|
export {
|
|
116
|
-
|
|
122
|
+
q as a,
|
|
123
|
+
O as p
|
|
117
124
|
};
|
|
@@ -1,174 +1,198 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { StateGraph as
|
|
3
|
-
import { g as T, O as R, P as C, t as N, Q as
|
|
2
|
+
import { StateGraph as I, START as k, END as v } from "@langchain/langgraph/web";
|
|
3
|
+
import { g as T, O as R, P as C, t as N, Q as V, f, R as D, r as z, S as b, T as P } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
6
|
+
import "@arcgis/toolkit/string";
|
|
7
|
+
import { h as _, e as Q } from "./generateLayerDescriptions.js";
|
|
8
|
+
import { AIMessage as O } from "@langchain/core/messages";
|
|
9
|
+
import { s as n } from "./index.js";
|
|
8
10
|
import "@langchain/openai";
|
|
11
|
+
import "@arcgis/core/config.js";
|
|
9
12
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
10
13
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
11
14
|
import "@arcgis/core/request.js";
|
|
12
15
|
import "@langchain/core/prompts";
|
|
13
|
-
import { h as
|
|
14
|
-
import { ToolNode as
|
|
16
|
+
import { h as $ } from "./toolCallResponse.js";
|
|
17
|
+
import { ToolNode as j } from "@langchain/langgraph/prebuilt";
|
|
15
18
|
import G from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
16
19
|
import U from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
17
|
-
const W = async (t, e) => (await
|
|
18
|
-
await
|
|
20
|
+
const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
|
|
21
|
+
await n({ text: "Requesting LLM for layer filter results" }, e);
|
|
19
22
|
const d = await T("data_explore_filter_prompt");
|
|
20
23
|
if (!e?.configurable)
|
|
21
24
|
throw new Error("config.configurable is required for layer filter tools");
|
|
22
|
-
const { userTimezone:
|
|
25
|
+
const { userTimezone: l, userTimezoneOffset: s } = R(), r = {
|
|
23
26
|
layerFieldInfo: t.layerFieldInfo,
|
|
24
|
-
userTimezone:
|
|
25
|
-
userTimezoneOffset:
|
|
27
|
+
userTimezone: l,
|
|
28
|
+
userTimezoneOffset: s,
|
|
26
29
|
queryResponse: t.queryResponse,
|
|
27
30
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
28
31
|
userRequest: t.agentExecutionContext.userRequest,
|
|
29
32
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
30
|
-
},
|
|
33
|
+
}, o = await _({
|
|
31
34
|
promptText: d,
|
|
32
35
|
modelTier: "advanced",
|
|
36
|
+
config: e,
|
|
33
37
|
messages: t.dataExplorationMessages,
|
|
34
|
-
inputVariables:
|
|
38
|
+
inputVariables: r,
|
|
35
39
|
tools: C
|
|
36
|
-
}), i = [...t.dataExplorationMessages,
|
|
37
|
-
if (!((
|
|
38
|
-
return await
|
|
40
|
+
}), i = [...t.dataExplorationMessages, o];
|
|
41
|
+
if (!((o.tool_calls?.length ?? 0) > 0))
|
|
42
|
+
return await n({ text: "LLM determined no filter changes needed" }, e), {
|
|
39
43
|
...t,
|
|
40
44
|
dataExplorationMessages: i
|
|
41
45
|
// Don't overwrite outputMessage if query already set it
|
|
42
46
|
};
|
|
43
|
-
const m =
|
|
44
|
-
return await
|
|
47
|
+
const m = i, g = o.content.toString();
|
|
48
|
+
return await $(o, e), { ...t, dataExplorationMessages: m, outputMessage: g };
|
|
45
49
|
}, H = async (t, e) => {
|
|
46
|
-
await
|
|
50
|
+
await n({ text: "Requesting LLM for layer query results" }, e);
|
|
47
51
|
const d = await T("data_explore_query_prompt");
|
|
48
52
|
if (!e?.configurable)
|
|
49
53
|
throw new Error("config.configurable is required for layer query tools");
|
|
50
|
-
const { userTimezone:
|
|
51
|
-
let
|
|
54
|
+
const { userTimezone: l, userTimezoneOffset: s } = R(), r = t.agentExecutionContext.sharedState, o = r.lastNavigatedFeatures?.value, i = r.lastResolvedLocation?.value;
|
|
55
|
+
let c = "none";
|
|
56
|
+
if (o != null)
|
|
57
|
+
try {
|
|
58
|
+
c = JSON.stringify(o);
|
|
59
|
+
} catch {
|
|
60
|
+
c = "none";
|
|
61
|
+
}
|
|
62
|
+
let m = "none";
|
|
52
63
|
if (i != null)
|
|
53
64
|
try {
|
|
54
|
-
|
|
65
|
+
m = JSON.stringify({
|
|
66
|
+
address: i.address,
|
|
67
|
+
location: i.location
|
|
68
|
+
});
|
|
55
69
|
} catch {
|
|
56
|
-
|
|
70
|
+
m = "none";
|
|
57
71
|
}
|
|
58
|
-
const
|
|
72
|
+
const g = {
|
|
59
73
|
layerFieldInfo: t.layerFieldInfo,
|
|
60
|
-
userTimezone:
|
|
61
|
-
userTimezoneOffset:
|
|
74
|
+
userTimezone: l,
|
|
75
|
+
userTimezoneOffset: s,
|
|
62
76
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
63
77
|
userRequest: t.agentExecutionContext.userRequest,
|
|
64
78
|
priorSteps: t.agentExecutionContext.priorSteps,
|
|
65
|
-
lastNavigatedFeatures:
|
|
66
|
-
|
|
79
|
+
lastNavigatedFeatures: c,
|
|
80
|
+
lastResolvedLocation: m
|
|
81
|
+
}, y = await _({
|
|
67
82
|
promptText: d,
|
|
68
83
|
modelTier: "advanced",
|
|
84
|
+
config: e,
|
|
69
85
|
messages: t.dataExplorationMessages,
|
|
70
|
-
inputVariables:
|
|
71
|
-
tools:
|
|
72
|
-
}), y =
|
|
73
|
-
return await
|
|
86
|
+
inputVariables: g,
|
|
87
|
+
tools: V
|
|
88
|
+
}), h = (y.tool_calls?.length ?? 0) > 0, p = y.content.toString();
|
|
89
|
+
return await $(y, e), {
|
|
74
90
|
...t,
|
|
75
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
76
|
-
|
|
91
|
+
dataExplorationMessages: [...t.dataExplorationMessages, y],
|
|
92
|
+
// Only emit output here when no tools are being called.
|
|
93
|
+
// For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
|
|
94
|
+
...h ? {} : { outputMessage: p },
|
|
77
95
|
status: "success",
|
|
78
|
-
summary:
|
|
96
|
+
summary: p && !h ? N(p) : "Query planning completed."
|
|
79
97
|
};
|
|
80
98
|
}, J = async (t, e) => {
|
|
81
99
|
try {
|
|
82
|
-
await
|
|
83
|
-
const d = await T("summarize_query_response_prompt"),
|
|
100
|
+
await n({ text: "Requesting LLM for summary on query results" }, e);
|
|
101
|
+
const d = await T("summarize_query_response_prompt"), l = {
|
|
84
102
|
queryResponse: t.queryResponse,
|
|
85
103
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
86
104
|
userRequest: t.agentExecutionContext.userRequest,
|
|
87
105
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
88
|
-
},
|
|
106
|
+
}, s = await Q({
|
|
89
107
|
promptText: d,
|
|
90
108
|
modelTier: "fast",
|
|
109
|
+
config: e,
|
|
91
110
|
messages: t.dataExplorationMessages,
|
|
92
|
-
inputVariables:
|
|
93
|
-
}),
|
|
94
|
-
await
|
|
95
|
-
const i =
|
|
111
|
+
inputVariables: l
|
|
112
|
+
}), r = typeof s == "string" ? s : s.content, o = new O(r);
|
|
113
|
+
await n({ text: `Received response from LLM: ${r}` }, e);
|
|
114
|
+
const i = r;
|
|
96
115
|
return {
|
|
97
116
|
...t,
|
|
98
117
|
outputMessage: i,
|
|
99
118
|
status: "success",
|
|
100
119
|
summary: i ? N(i) : "Summary generated.",
|
|
101
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
120
|
+
dataExplorationMessages: [...t.dataExplorationMessages, o]
|
|
102
121
|
};
|
|
103
122
|
} catch (a) {
|
|
104
|
-
throw await
|
|
123
|
+
throw await n({ text: "Error during filter LLM request" }, e), new Error(`Error during filter LLM request: ${a instanceof Error ? a.message : String(a)}`);
|
|
105
124
|
}
|
|
106
125
|
};
|
|
107
126
|
async function K(t, e) {
|
|
108
|
-
|
|
127
|
+
if ((t.queryResponse ?? []).some((s) => {
|
|
128
|
+
const r = s.details;
|
|
129
|
+
return typeof r == "object" && r !== null && "error" in r;
|
|
130
|
+
}))
|
|
131
|
+
return await n({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
|
|
132
|
+
const l = await new j(C, { handleToolErrors: !1 }).invoke(
|
|
109
133
|
{
|
|
110
134
|
messages: t.dataExplorationMessages
|
|
111
135
|
},
|
|
112
136
|
e
|
|
113
137
|
);
|
|
114
|
-
return await
|
|
115
|
-
{ text: `Finished executing layer filter tool: ${
|
|
138
|
+
return await n(
|
|
139
|
+
{ text: `Finished executing layer filter tool: ${l.messages.map((s) => s.content).join(", ")}` },
|
|
116
140
|
e
|
|
117
141
|
), { ...t };
|
|
118
142
|
}
|
|
119
143
|
const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { includeSummaryStatistics: a = !0, includeUniqueValues: d = !0 } = {}) => {
|
|
120
|
-
let
|
|
144
|
+
let l = null, s = null;
|
|
121
145
|
try {
|
|
122
146
|
if (e.type !== "geometry" && e.type !== "oid" && e.type !== "global-id") {
|
|
123
|
-
a && (
|
|
124
|
-
const
|
|
125
|
-
d && (Y.includes(e.type) ||
|
|
126
|
-
...
|
|
127
|
-
value:
|
|
147
|
+
a && (l = await G({ layer: t, field: e.name }));
|
|
148
|
+
const r = e.domain?.type === "coded-value" ? e.domain : null;
|
|
149
|
+
d && (Y.includes(e.type) || r) && (s = (await U({ layer: t, field: e.name })).uniqueValueInfos.sort((o, i) => i.count - o.count).slice(0, X), r && (s = s.map((o) => ({
|
|
150
|
+
...o,
|
|
151
|
+
value: r.getName(o.value) ?? o.value
|
|
128
152
|
}))));
|
|
129
153
|
}
|
|
130
|
-
} catch (
|
|
131
|
-
console.error(`Error fetching statistics for field ${e.name}:`,
|
|
154
|
+
} catch (r) {
|
|
155
|
+
console.error(`Error fetching statistics for field ${e.name}:`, r);
|
|
132
156
|
}
|
|
133
157
|
return {
|
|
134
|
-
summaryStatistics:
|
|
135
|
-
uniqueValues:
|
|
158
|
+
summaryStatistics: l,
|
|
159
|
+
uniqueValues: s
|
|
136
160
|
};
|
|
137
161
|
};
|
|
138
162
|
function ee(t, e) {
|
|
139
163
|
return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
|
|
140
164
|
}
|
|
141
165
|
async function te(t, e, a, d = !0) {
|
|
142
|
-
const
|
|
143
|
-
for (const
|
|
144
|
-
let i = function(
|
|
145
|
-
const u = e.get(
|
|
166
|
+
const l = [], s = [], r = [];
|
|
167
|
+
for (const o of t) {
|
|
168
|
+
let i = function(p) {
|
|
169
|
+
const u = e.get(p)?.layerItem;
|
|
146
170
|
return u ? [
|
|
147
171
|
u.name && `Name: ${u.name}`,
|
|
148
172
|
u.title && `Title: ${u.title}`,
|
|
149
173
|
u.description && `Description: ${u.description}`
|
|
150
|
-
].filter(Boolean).join(" | ") :
|
|
174
|
+
].filter(Boolean).join(" | ") : p;
|
|
151
175
|
};
|
|
152
|
-
const { layerId:
|
|
176
|
+
const { layerId: c, results: m } = o, g = a.map?.allLayers.find((p) => p.id === c), y = e.get(c)?.fieldRegistry;
|
|
153
177
|
if (!y)
|
|
154
178
|
continue;
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
layerId:
|
|
158
|
-
layerSummary: i(
|
|
179
|
+
let h = l.find((p) => p.layerId === c);
|
|
180
|
+
h || (h = {
|
|
181
|
+
layerId: c,
|
|
182
|
+
layerSummary: i(c),
|
|
159
183
|
fieldInfos: []
|
|
160
|
-
},
|
|
161
|
-
for (const
|
|
162
|
-
const u = y.get(
|
|
184
|
+
}, l.push(h));
|
|
185
|
+
for (const p of m) {
|
|
186
|
+
const u = y.get(p.name);
|
|
163
187
|
if (!u)
|
|
164
188
|
continue;
|
|
165
189
|
const x = u.statistics, E = d && !x?.summaryStatistics, w = ee(u.type, u.domain?.type) && !x?.uniqueValues, q = E || w;
|
|
166
|
-
if (
|
|
167
|
-
layerId:
|
|
190
|
+
if (r.push({
|
|
191
|
+
layerId: c,
|
|
168
192
|
fieldName: u.name,
|
|
169
193
|
didFetchStatistics: q
|
|
170
194
|
}), q) {
|
|
171
|
-
const
|
|
195
|
+
const A = Z(g, u, {
|
|
172
196
|
includeSummaryStatistics: E,
|
|
173
197
|
includeUniqueValues: w
|
|
174
198
|
}).then((F) => {
|
|
@@ -178,90 +202,90 @@ async function te(t, e, a, d = !0) {
|
|
|
178
202
|
};
|
|
179
203
|
E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), y.set(u.name, { ...u, statistics: S }), u.statistics = S;
|
|
180
204
|
});
|
|
181
|
-
|
|
205
|
+
s.push(A);
|
|
182
206
|
}
|
|
183
|
-
|
|
207
|
+
h.fieldInfos.push(u);
|
|
184
208
|
}
|
|
185
209
|
}
|
|
186
|
-
return await Promise.all(
|
|
187
|
-
layerFieldInfo:
|
|
188
|
-
didFetchStatistics:
|
|
189
|
-
fieldStatisticsFetchStatus:
|
|
210
|
+
return await Promise.all(s), {
|
|
211
|
+
layerFieldInfo: l,
|
|
212
|
+
didFetchStatistics: s.length > 0,
|
|
213
|
+
fieldStatisticsFetchStatus: r
|
|
190
214
|
};
|
|
191
215
|
}
|
|
192
|
-
const
|
|
216
|
+
const L = /\b(average|avg|mean|median|max(?:imum)?|min(?:imum)?|sum|total|count|std(?:dev|\s*deviation)|variance|null\s*count|missing\s*values?|range)\b/iu;
|
|
193
217
|
function ae(t, e) {
|
|
194
|
-
return
|
|
218
|
+
return L.test(t) || L.test(e);
|
|
195
219
|
}
|
|
196
220
|
const se = async (t, e) => {
|
|
197
221
|
try {
|
|
198
|
-
await
|
|
199
|
-
const a =
|
|
222
|
+
await n({ text: "Preparing field information for vector search results" }, e);
|
|
223
|
+
const a = f(e, "layersAndFieldsRegistry"), { mapView: d } = D(e), { assignedTask: l, userRequest: s } = t.agentExecutionContext, r = ae(l, s), { layerFieldInfo: o, didFetchStatistics: i, fieldStatisticsFetchStatus: c } = await te(
|
|
200
224
|
t.vectorSearchFieldResults,
|
|
201
225
|
a,
|
|
202
226
|
d,
|
|
203
|
-
|
|
227
|
+
r
|
|
204
228
|
);
|
|
205
|
-
i ? await
|
|
206
|
-
for (const m of
|
|
207
|
-
await
|
|
229
|
+
i ? await n({ text: "Statistics fetched" }, e) : await n({ text: "Statistics skipped" }, e);
|
|
230
|
+
for (const m of c)
|
|
231
|
+
await n(
|
|
208
232
|
{
|
|
209
233
|
text: ` - ${m.fieldName} - stats ${m.didFetchStatistics ? "fetched" : "skipped"}`
|
|
210
234
|
},
|
|
211
235
|
e
|
|
212
236
|
);
|
|
213
|
-
return await
|
|
237
|
+
return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: o };
|
|
214
238
|
} catch (a) {
|
|
215
|
-
throw await
|
|
239
|
+
throw await n({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
|
|
216
240
|
}
|
|
217
|
-
},
|
|
241
|
+
}, M = 0.7, re = 10, oe = async (t, e) => {
|
|
218
242
|
try {
|
|
219
|
-
await
|
|
220
|
-
const a =
|
|
243
|
+
await n({ text: "Similarity search to find fields" }, e);
|
|
244
|
+
const a = f(e, "fieldSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchFields({
|
|
221
245
|
text: t.agentExecutionContext.assignedTask,
|
|
222
246
|
layerIds: t.vectorSearchLayerIds,
|
|
223
|
-
minScore:
|
|
247
|
+
minScore: M,
|
|
224
248
|
topResults: re,
|
|
225
|
-
embeddingCache:
|
|
226
|
-
}),
|
|
227
|
-
const m =
|
|
249
|
+
embeddingCache: l
|
|
250
|
+
}), r = s.map(({ layerId: i, results: c }) => {
|
|
251
|
+
const m = c.map((g) => ` - ${g.name} (${g.score.toFixed(2)})`).join(`
|
|
228
252
|
`);
|
|
229
253
|
return `${d.get(i)?.layerItem.name ?? i}:
|
|
230
254
|
${m}`;
|
|
231
255
|
}).join(`
|
|
232
256
|
`);
|
|
233
|
-
let
|
|
234
|
-
return
|
|
235
|
-
${
|
|
257
|
+
let o;
|
|
258
|
+
return s.length > 0 ? o = `Vector search completed. Matching layers and fields with scores:
|
|
259
|
+
${r}` : o = `No vector search results found for score over ${M}.`, await n({ text: o }, e), {
|
|
236
260
|
...t,
|
|
237
|
-
vectorSearchFieldResults:
|
|
261
|
+
vectorSearchFieldResults: s
|
|
238
262
|
};
|
|
239
263
|
} catch (a) {
|
|
240
|
-
throw await
|
|
264
|
+
throw await n(
|
|
241
265
|
{ text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
|
|
242
266
|
e
|
|
243
267
|
), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
|
|
244
268
|
}
|
|
245
269
|
}, ie = 0.7, ne = async (t, e) => {
|
|
246
270
|
try {
|
|
247
|
-
await
|
|
271
|
+
await n(
|
|
248
272
|
{ text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
|
|
249
273
|
e
|
|
250
274
|
);
|
|
251
|
-
const a =
|
|
275
|
+
const a = f(e, "layerSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchLayers({
|
|
252
276
|
text: t.agentExecutionContext.assignedTask,
|
|
253
277
|
minScore: ie,
|
|
254
|
-
embeddingCache:
|
|
255
|
-
}),
|
|
278
|
+
embeddingCache: l
|
|
279
|
+
}), r = s.map((c) => c.id), o = s.map(({ id: c, score: m }) => `${d.get(c)?.layerItem.name ?? c} (${m.toFixed(2)})`).join(`
|
|
256
280
|
`);
|
|
257
281
|
let i;
|
|
258
|
-
return
|
|
259
|
-
${
|
|
282
|
+
return r.length > 0 ? i = `Vector search completed. Matching layers with scores:
|
|
283
|
+
${o}` : i = "Vector search completed. No matching layers found.", await n({ text: i }, e), {
|
|
260
284
|
...t,
|
|
261
|
-
vectorSearchLayerIds:
|
|
285
|
+
vectorSearchLayerIds: r
|
|
262
286
|
};
|
|
263
287
|
} catch (a) {
|
|
264
|
-
throw await
|
|
288
|
+
throw await n(
|
|
265
289
|
{ text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
|
|
266
290
|
e
|
|
267
291
|
), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
|
|
@@ -269,7 +293,7 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
|
|
|
269
293
|
}, le = (t, e) => z(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
|
|
270
294
|
t,
|
|
271
295
|
e
|
|
272
|
-
), ce = () => new b
|
|
296
|
+
), ce = () => new I(b).addNode("requireDataExplorationServices", le).addNode("vectorSearchLayers", ne).addNode("vectorSearchFields", oe).addNode("fieldStatistics", se).addNode("queryAgent", H).addNode("queryTools", P).addNode("summarizeQueryResponseLLM", J).addNode("filterAgent", B).addNode("filterTools", K).addNode("earlyExit", W).addEdge(k, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
|
|
273
297
|
"vectorSearchLayers",
|
|
274
298
|
(e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
275
299
|
).addConditionalEdges(
|
|
@@ -286,13 +310,15 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
|
|
|
286
310
|
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”). However, this agent does not handle addresses.
|
|
287
311
|
_Example: “How many features are there?”_
|
|
288
312
|
_Example: “What’s the average population?”_
|
|
289
|
-
_Example: “Which values are in the status field?”_
|
|
313
|
+
_Example: “Which values are in the status field?”_
|
|
314
|
+
|
|
315
|
+
This agent does NOT handle help/metadata requests such as listing available layers, listing field names/columns/attributes for a layer, or capability guidance.`, Ce = {
|
|
290
316
|
id: "dataExploration",
|
|
291
317
|
name: "Data Exploration Agent",
|
|
292
318
|
description: de,
|
|
293
319
|
createGraph: ce,
|
|
294
|
-
workspace:
|
|
320
|
+
workspace: b
|
|
295
321
|
};
|
|
296
322
|
export {
|
|
297
|
-
|
|
323
|
+
Ce as D
|
|
298
324
|
};
|
|
@@ -39,10 +39,13 @@ Prior steps:
|
|
|
39
39
|
Last navigated features from shared state (if available):
|
|
40
40
|
{lastNavigatedFeatures}
|
|
41
41
|
|
|
42
|
+
Last resolved location from shared state (if available):
|
|
43
|
+
{lastResolvedLocation}
|
|
44
|
+
|
|
42
45
|
Use the assigned task as the primary instruction for the current query.
|
|
43
46
|
Use the latest user request as supporting context when needed.
|
|
44
47
|
Use prior steps only when the assigned task or user request clearly depends on earlier results.
|
|
45
|
-
Use
|
|
48
|
+
Use shared-state context (\`lastResolvedLocation\`, \`lastNavigatedFeatures\`) for referential follow-ups when relevant.
|
|
46
49
|
Use chat history only when necessary to understand conversational references, and do not override the assigned task.
|
|
47
50
|
|
|
48
51
|
### Anchor selection rule (strict, single source of truth)
|
|
@@ -50,8 +53,9 @@ Use chat history only when necessary to understand conversational references, an
|
|
|
50
53
|
When the request is referential (for example: "this", "it", "that", "those", "them", "of those", "the same one(s)"), choose exactly one anchor using this priority order:
|
|
51
54
|
|
|
52
55
|
1. Explicit entity named in the current request (if present)
|
|
53
|
-
2. \`
|
|
54
|
-
3.
|
|
56
|
+
2. \`lastResolvedLocation\` (if present and the request refers to a place/location)
|
|
57
|
+
3. \`lastNavigatedFeatures\` (if present)
|
|
58
|
+
4. The immediately previous successful relevant step from \`priorSteps\`
|
|
55
59
|
|
|
56
60
|
After selecting the anchor, keep that anchor for this query and do not switch to an older entity.
|
|
57
61
|
If \`lastNavigatedFeatures\` is used as the anchor, reuse its \`layerId\` and \`where\` for query scope unless the current request explicitly overrides it.
|
|
@@ -78,7 +82,8 @@ Start with a fresh WHERE clause for each new question. Do not inherit filters fr
|
|
|
78
82
|
|
|
79
83
|
This is an exception to the "fresh WHERE clause" rule above.
|
|
80
84
|
|
|
81
|
-
- If the anchored context
|
|
85
|
+
- If the anchored context is \`lastResolvedLocation\` with a point, prefer \`geometryFilter.point\` and use \`where: "1=1"\` unless the user asked for additional attribute filters.
|
|
86
|
+
- Only use \`useCurrentExtent: true\` when the user explicitly asks about the current view/map extent (for example: "in my view", "on my map", "visible now").
|
|
82
87
|
- If the anchored context includes specific feature IDs/objectIds, scope to those IDs.
|
|
83
88
|
- Otherwise, use the anchored \`layerId\` + \`where\` combination.
|
|
84
89
|
|