@arcgis/ai-components 5.2.0-next.1 → 5.2.0-next.11
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 +22 -22
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +99 -0
- package/dist/agent-utils/index.js +148 -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 +30 -1
- 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/{V2P4AIGG.js → 24QNMEFG.js} +1 -1
- package/dist/cdn/{NAUXSHIE.js → 34SG44C3.js} +2 -2
- package/dist/cdn/3JGWGKT6.js +2 -0
- package/dist/cdn/3NBDVZ2I.js +2 -0
- package/dist/cdn/3VOQD2MR.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/53NTYC4I.js +2 -0
- package/dist/cdn/{4HU7735A.js → 5CV7R5IS.js} +6 -4
- package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
- package/dist/cdn/{FL4W4VYN.js → 6ZW7Z36F.js} +16 -0
- package/dist/cdn/7CYGX4F4.js +2 -0
- package/dist/cdn/{DHOVCT6R.js → AZGGTNA3.js} +1 -1
- package/dist/cdn/B7WJFBOZ.js +2 -0
- package/dist/cdn/BX7FSMUU.js +56 -0
- package/dist/cdn/CHPQM77M.js +181 -0
- package/dist/cdn/DHKUXLU3.js +179 -0
- package/dist/cdn/DQSEBKOX.js +2 -0
- package/dist/cdn/DXVU45KM.js +2 -0
- package/dist/cdn/{P6OPJQMC.js → DZ2QWNUA.js} +1 -1
- package/dist/cdn/EBISDZ5H.js +2 -0
- package/dist/cdn/{MDVYQQUG.js → ERL2CB2Y.js} +5 -5
- package/dist/cdn/F6QHMKF5.js +2 -0
- package/dist/cdn/FUIGPHBH.js +2 -0
- package/dist/cdn/{AO7BQHKC.js → H2CHHGGH.js} +1 -1
- package/dist/cdn/{OH64RMOR.js → HWKDNS4K.js} +2 -2
- package/dist/cdn/IMQ4TVHF.js +16 -0
- package/dist/cdn/IOD3GDA7.js +2 -0
- package/dist/cdn/IR7PTESF.js +2 -0
- package/dist/cdn/IRZDTYO2.js +2 -0
- package/dist/cdn/JIWK6QK6.js +2 -0
- package/dist/cdn/{S6W6HV4T.js → JLKGS6Y5.js} +12 -12
- package/dist/cdn/K3JCH4XW.js +2 -0
- package/dist/cdn/KHXUWZHB.js +2 -0
- package/dist/cdn/LIFK3QSD.js +2 -0
- package/dist/cdn/NXKKG5TK.js +2 -0
- package/dist/cdn/{FX5JFRDL.js → O3EN27N5.js} +1 -1
- package/dist/cdn/O3RFFPU3.js +6 -0
- package/dist/cdn/P7DG5T3Z.js +9 -0
- package/dist/cdn/PBO6FZN6.js +2 -0
- package/dist/cdn/Q3ZW4FYA.js +3 -0
- package/dist/cdn/Q6LRANX6.js +2 -0
- package/dist/cdn/Q7TL5Q5N.js +2 -0
- package/dist/cdn/QCSN44H4.js +2 -0
- package/dist/cdn/R56X6ZKR.js +161 -0
- package/dist/cdn/{HB5A5R2E.js → RUURNLTP.js} +1 -1
- package/dist/cdn/T43LEBBE.js +47 -0
- package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
- package/dist/cdn/TR4GFL7X.js +2 -0
- package/dist/cdn/{3PKJWIC3.js → UPEEHMSY.js} +1 -1
- package/dist/cdn/WAIFKDR3.js +2 -0
- package/dist/cdn/WNS5ZUF5.js +2 -0
- package/dist/cdn/X4XY5HIE.js +2 -0
- package/dist/cdn/XOH56EQ2.js +2 -0
- package/dist/cdn/XON27U6U.js +2 -0
- package/dist/cdn/{H7422XUG.js → YLN2BZ5J.js} +1 -1
- package/dist/cdn/{2AXF774U.js → YUKR4AZW.js} +1 -1
- package/dist/cdn/{JY6LLOUJ.js → Z2G7MP5L.js} +3 -3
- package/dist/cdn/ZEYIBYSF.js +66 -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 +1390 -1323
- package/dist/chunks/arcgisKnowledgeGraph.js +109 -72
- package/dist/chunks/dataExplorationGraph.js +108 -96
- package/dist/chunks/generateLayerDescriptions.js +206 -168
- package/dist/chunks/helpGraph.js +16 -13
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +23 -20
- package/dist/chunks/navigationGraph.js +34 -30
- package/dist/chunks/orchestrator.js +241 -201
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +5 -3
- package/dist/components/arcgis-assistant/customElement.d.ts +15 -0
- package/dist/components/arcgis-assistant/customElement.js +228 -127
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +7 -7
- 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 +1 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +13 -9
- 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 +1 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- 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 +4 -1
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
- 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 +1 -1
- 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 +6 -5
- package/dist/orchestrator/registry/agentRegistry.d.ts +33 -0
- package/dist/types/lumina.d.ts +10 -4
- package/dist/types/preact.d.ts +11 -4
- package/dist/types/react.d.ts +12 -4
- package/dist/types/stencil.d.ts +10 -4
- package/dist/utils/index.d.ts +87 -43
- package/dist/utils/index.js +54 -49
- package/package.json +8 -7
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/FHVXO2WG.js +0 -166
- package/dist/cdn/GSEPHN3A.js +0 -106
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/ON2V5XI2.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V5YEZSRY.js +0 -16
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YY2SBO3V.js +0 -2
|
@@ -1,174 +1,186 @@
|
|
|
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 as h, 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 {
|
|
6
|
+
import { h as _, e as Q } from "./generateLayerDescriptions.js";
|
|
7
7
|
import { AIMessage as j } from "@langchain/core/messages";
|
|
8
|
+
import { s as n } from "./index.js";
|
|
8
9
|
import "@langchain/openai";
|
|
10
|
+
import "@arcgis/core/config.js";
|
|
9
11
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
10
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
11
13
|
import "@arcgis/core/request.js";
|
|
12
14
|
import "@langchain/core/prompts";
|
|
13
|
-
import { h as
|
|
15
|
+
import { h as $ } from "./toolCallResponse.js";
|
|
14
16
|
import { ToolNode as O } from "@langchain/langgraph/prebuilt";
|
|
15
17
|
import G from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
16
18
|
import U from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
17
|
-
const W = async (t, e) => (await
|
|
18
|
-
await
|
|
19
|
+
const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
|
|
20
|
+
await n({ text: "Requesting LLM for layer filter results" }, e);
|
|
19
21
|
const d = await T("data_explore_filter_prompt");
|
|
20
22
|
if (!e?.configurable)
|
|
21
23
|
throw new Error("config.configurable is required for layer filter tools");
|
|
22
|
-
const { userTimezone:
|
|
24
|
+
const { userTimezone: l, userTimezoneOffset: s } = R(), o = {
|
|
23
25
|
layerFieldInfo: t.layerFieldInfo,
|
|
24
|
-
userTimezone:
|
|
25
|
-
userTimezoneOffset:
|
|
26
|
+
userTimezone: l,
|
|
27
|
+
userTimezoneOffset: s,
|
|
26
28
|
queryResponse: t.queryResponse,
|
|
27
29
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
28
30
|
userRequest: t.agentExecutionContext.userRequest,
|
|
29
31
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
30
|
-
},
|
|
32
|
+
}, r = await _({
|
|
31
33
|
promptText: d,
|
|
32
34
|
modelTier: "advanced",
|
|
35
|
+
config: e,
|
|
33
36
|
messages: t.dataExplorationMessages,
|
|
34
37
|
inputVariables: o,
|
|
35
38
|
tools: C
|
|
36
|
-
}), i = [...t.dataExplorationMessages,
|
|
37
|
-
if (!((
|
|
38
|
-
return await
|
|
39
|
+
}), i = [...t.dataExplorationMessages, r];
|
|
40
|
+
if (!((r.tool_calls?.length ?? 0) > 0))
|
|
41
|
+
return await n({ text: "LLM determined no filter changes needed" }, e), {
|
|
39
42
|
...t,
|
|
40
43
|
dataExplorationMessages: i
|
|
41
44
|
// Don't overwrite outputMessage if query already set it
|
|
42
45
|
};
|
|
43
|
-
const m =
|
|
44
|
-
return await
|
|
46
|
+
const m = i, p = r.content.toString();
|
|
47
|
+
return await $(r, e), { ...t, dataExplorationMessages: m, outputMessage: p };
|
|
45
48
|
}, H = async (t, e) => {
|
|
46
|
-
await
|
|
49
|
+
await n({ text: "Requesting LLM for layer query results" }, e);
|
|
47
50
|
const d = await T("data_explore_query_prompt");
|
|
48
51
|
if (!e?.configurable)
|
|
49
52
|
throw new Error("config.configurable is required for layer query tools");
|
|
50
|
-
const { userTimezone:
|
|
51
|
-
let
|
|
53
|
+
const { userTimezone: l, userTimezoneOffset: s } = R(), r = t.agentExecutionContext.sharedState.lastNavigatedFeatures, i = r && typeof r == "object" && "value" in r ? r.value : r;
|
|
54
|
+
let c = "none";
|
|
52
55
|
if (i != null)
|
|
53
56
|
try {
|
|
54
|
-
|
|
57
|
+
c = JSON.stringify(i);
|
|
55
58
|
} catch {
|
|
56
|
-
|
|
59
|
+
c = "none";
|
|
57
60
|
}
|
|
58
61
|
const m = {
|
|
59
62
|
layerFieldInfo: t.layerFieldInfo,
|
|
60
|
-
userTimezone:
|
|
61
|
-
userTimezoneOffset:
|
|
63
|
+
userTimezone: l,
|
|
64
|
+
userTimezoneOffset: s,
|
|
62
65
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
63
66
|
userRequest: t.agentExecutionContext.userRequest,
|
|
64
67
|
priorSteps: t.agentExecutionContext.priorSteps,
|
|
65
|
-
lastNavigatedFeatures:
|
|
66
|
-
}, p = await
|
|
68
|
+
lastNavigatedFeatures: c
|
|
69
|
+
}, p = await _({
|
|
67
70
|
promptText: d,
|
|
68
71
|
modelTier: "advanced",
|
|
72
|
+
config: e,
|
|
69
73
|
messages: t.dataExplorationMessages,
|
|
70
74
|
inputVariables: m,
|
|
71
|
-
tools:
|
|
72
|
-
}),
|
|
73
|
-
return await
|
|
75
|
+
tools: V
|
|
76
|
+
}), f = (p.tool_calls?.length ?? 0) > 0, g = p.content.toString();
|
|
77
|
+
return await $(p, e), {
|
|
74
78
|
...t,
|
|
75
79
|
dataExplorationMessages: [...t.dataExplorationMessages, p],
|
|
76
|
-
|
|
80
|
+
// Only emit output here when no tools are being called.
|
|
81
|
+
// For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
|
|
82
|
+
...f ? {} : { outputMessage: g },
|
|
77
83
|
status: "success",
|
|
78
|
-
summary:
|
|
84
|
+
summary: g && !f ? N(g) : "Query planning completed."
|
|
79
85
|
};
|
|
80
86
|
}, J = async (t, e) => {
|
|
81
87
|
try {
|
|
82
|
-
await
|
|
83
|
-
const d = await T("summarize_query_response_prompt"),
|
|
88
|
+
await n({ text: "Requesting LLM for summary on query results" }, e);
|
|
89
|
+
const d = await T("summarize_query_response_prompt"), l = {
|
|
84
90
|
queryResponse: t.queryResponse,
|
|
85
91
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
86
92
|
userRequest: t.agentExecutionContext.userRequest,
|
|
87
93
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
88
|
-
},
|
|
94
|
+
}, s = await Q({
|
|
89
95
|
promptText: d,
|
|
90
96
|
modelTier: "fast",
|
|
97
|
+
config: e,
|
|
91
98
|
messages: t.dataExplorationMessages,
|
|
92
|
-
inputVariables:
|
|
93
|
-
}), o = typeof
|
|
94
|
-
await
|
|
99
|
+
inputVariables: l
|
|
100
|
+
}), o = typeof s == "string" ? s : s.content, r = new j(o);
|
|
101
|
+
await n({ text: `Received response from LLM: ${o}` }, e);
|
|
95
102
|
const i = o;
|
|
96
103
|
return {
|
|
97
104
|
...t,
|
|
98
105
|
outputMessage: i,
|
|
99
106
|
status: "success",
|
|
100
107
|
summary: i ? N(i) : "Summary generated.",
|
|
101
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
108
|
+
dataExplorationMessages: [...t.dataExplorationMessages, r]
|
|
102
109
|
};
|
|
103
110
|
} catch (a) {
|
|
104
|
-
throw await
|
|
111
|
+
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
112
|
}
|
|
106
113
|
};
|
|
107
114
|
async function K(t, e) {
|
|
108
|
-
|
|
115
|
+
if ((t.queryResponse ?? []).some((s) => {
|
|
116
|
+
const o = s.details;
|
|
117
|
+
return typeof o == "object" && o !== null && "error" in o;
|
|
118
|
+
}))
|
|
119
|
+
return await n({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
|
|
120
|
+
const l = await new O(C, { handleToolErrors: !1 }).invoke(
|
|
109
121
|
{
|
|
110
122
|
messages: t.dataExplorationMessages
|
|
111
123
|
},
|
|
112
124
|
e
|
|
113
125
|
);
|
|
114
|
-
return await
|
|
115
|
-
{ text: `Finished executing layer filter tool: ${
|
|
126
|
+
return await n(
|
|
127
|
+
{ text: `Finished executing layer filter tool: ${l.messages.map((s) => s.content).join(", ")}` },
|
|
116
128
|
e
|
|
117
129
|
), { ...t };
|
|
118
130
|
}
|
|
119
131
|
const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { includeSummaryStatistics: a = !0, includeUniqueValues: d = !0 } = {}) => {
|
|
120
|
-
let
|
|
132
|
+
let l = null, s = null;
|
|
121
133
|
try {
|
|
122
134
|
if (e.type !== "geometry" && e.type !== "oid" && e.type !== "global-id") {
|
|
123
|
-
a && (
|
|
135
|
+
a && (l = await G({ layer: t, field: e.name }));
|
|
124
136
|
const o = e.domain?.type === "coded-value" ? e.domain : null;
|
|
125
|
-
d && (Y.includes(e.type) || o) && (
|
|
126
|
-
...
|
|
127
|
-
value: o.getName(
|
|
137
|
+
d && (Y.includes(e.type) || o) && (s = (await U({ layer: t, field: e.name })).uniqueValueInfos.sort((r, i) => i.count - r.count).slice(0, X), o && (s = s.map((r) => ({
|
|
138
|
+
...r,
|
|
139
|
+
value: o.getName(r.value) ?? r.value
|
|
128
140
|
}))));
|
|
129
141
|
}
|
|
130
142
|
} catch (o) {
|
|
131
143
|
console.error(`Error fetching statistics for field ${e.name}:`, o);
|
|
132
144
|
}
|
|
133
145
|
return {
|
|
134
|
-
summaryStatistics:
|
|
135
|
-
uniqueValues:
|
|
146
|
+
summaryStatistics: l,
|
|
147
|
+
uniqueValues: s
|
|
136
148
|
};
|
|
137
149
|
};
|
|
138
150
|
function ee(t, e) {
|
|
139
151
|
return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
|
|
140
152
|
}
|
|
141
153
|
async function te(t, e, a, d = !0) {
|
|
142
|
-
const
|
|
143
|
-
for (const
|
|
144
|
-
let i = function(
|
|
145
|
-
const u = e.get(
|
|
154
|
+
const l = [], s = [], o = [];
|
|
155
|
+
for (const r of t) {
|
|
156
|
+
let i = function(y) {
|
|
157
|
+
const u = e.get(y)?.layerItem;
|
|
146
158
|
return u ? [
|
|
147
159
|
u.name && `Name: ${u.name}`,
|
|
148
160
|
u.title && `Title: ${u.title}`,
|
|
149
161
|
u.description && `Description: ${u.description}`
|
|
150
|
-
].filter(Boolean).join(" | ") :
|
|
162
|
+
].filter(Boolean).join(" | ") : y;
|
|
151
163
|
};
|
|
152
|
-
const { layerId:
|
|
153
|
-
if (!
|
|
164
|
+
const { layerId: c, results: m } = r, p = a.map?.allLayers.find((y) => y.id === c), f = e.get(c)?.fieldRegistry;
|
|
165
|
+
if (!f)
|
|
154
166
|
continue;
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
layerId:
|
|
158
|
-
layerSummary: i(
|
|
167
|
+
let g = l.find((y) => y.layerId === c);
|
|
168
|
+
g || (g = {
|
|
169
|
+
layerId: c,
|
|
170
|
+
layerSummary: i(c),
|
|
159
171
|
fieldInfos: []
|
|
160
|
-
},
|
|
161
|
-
for (const
|
|
162
|
-
const u =
|
|
172
|
+
}, l.push(g));
|
|
173
|
+
for (const y of m) {
|
|
174
|
+
const u = f.get(y.name);
|
|
163
175
|
if (!u)
|
|
164
176
|
continue;
|
|
165
177
|
const x = u.statistics, E = d && !x?.summaryStatistics, w = ee(u.type, u.domain?.type) && !x?.uniqueValues, q = E || w;
|
|
166
178
|
if (o.push({
|
|
167
|
-
layerId:
|
|
179
|
+
layerId: c,
|
|
168
180
|
fieldName: u.name,
|
|
169
181
|
didFetchStatistics: q
|
|
170
182
|
}), q) {
|
|
171
|
-
const
|
|
183
|
+
const A = Z(p, u, {
|
|
172
184
|
includeSummaryStatistics: E,
|
|
173
185
|
includeUniqueValues: w
|
|
174
186
|
}).then((F) => {
|
|
@@ -176,16 +188,16 @@ async function te(t, e, a, d = !0) {
|
|
|
176
188
|
summaryStatistics: x?.summaryStatistics ?? null,
|
|
177
189
|
uniqueValues: x?.uniqueValues ?? null
|
|
178
190
|
};
|
|
179
|
-
E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues),
|
|
191
|
+
E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), f.set(u.name, { ...u, statistics: S }), u.statistics = S;
|
|
180
192
|
});
|
|
181
|
-
|
|
193
|
+
s.push(A);
|
|
182
194
|
}
|
|
183
|
-
|
|
195
|
+
g.fieldInfos.push(u);
|
|
184
196
|
}
|
|
185
197
|
}
|
|
186
|
-
return await Promise.all(
|
|
187
|
-
layerFieldInfo:
|
|
188
|
-
didFetchStatistics:
|
|
198
|
+
return await Promise.all(s), {
|
|
199
|
+
layerFieldInfo: l,
|
|
200
|
+
didFetchStatistics: s.length > 0,
|
|
189
201
|
fieldStatisticsFetchStatus: o
|
|
190
202
|
};
|
|
191
203
|
}
|
|
@@ -195,73 +207,73 @@ function ae(t, e) {
|
|
|
195
207
|
}
|
|
196
208
|
const se = async (t, e) => {
|
|
197
209
|
try {
|
|
198
|
-
await
|
|
199
|
-
const a = h(e, "layersAndFieldsRegistry"), { mapView: d } = D(e), { assignedTask:
|
|
210
|
+
await n({ text: "Preparing field information for vector search results" }, e);
|
|
211
|
+
const a = h(e, "layersAndFieldsRegistry"), { mapView: d } = D(e), { assignedTask: l, userRequest: s } = t.agentExecutionContext, o = ae(l, s), { layerFieldInfo: r, didFetchStatistics: i, fieldStatisticsFetchStatus: c } = await te(
|
|
200
212
|
t.vectorSearchFieldResults,
|
|
201
213
|
a,
|
|
202
214
|
d,
|
|
203
215
|
o
|
|
204
216
|
);
|
|
205
|
-
i ? await
|
|
206
|
-
for (const m of
|
|
207
|
-
await
|
|
217
|
+
i ? await n({ text: "Statistics fetched" }, e) : await n({ text: "Statistics skipped" }, e);
|
|
218
|
+
for (const m of c)
|
|
219
|
+
await n(
|
|
208
220
|
{
|
|
209
221
|
text: ` - ${m.fieldName} - stats ${m.didFetchStatistics ? "fetched" : "skipped"}`
|
|
210
222
|
},
|
|
211
223
|
e
|
|
212
224
|
);
|
|
213
|
-
return await
|
|
225
|
+
return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: r };
|
|
214
226
|
} catch (a) {
|
|
215
|
-
throw await
|
|
227
|
+
throw await n({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
|
|
216
228
|
}
|
|
217
229
|
}, L = 0.7, re = 10, oe = async (t, e) => {
|
|
218
230
|
try {
|
|
219
|
-
await
|
|
220
|
-
const a = h(e, "fieldSearch"), d = h(e, "layersAndFieldsRegistry"),
|
|
231
|
+
await n({ text: "Similarity search to find fields" }, e);
|
|
232
|
+
const a = h(e, "fieldSearch"), d = h(e, "layersAndFieldsRegistry"), l = h(e, "embeddingCache"), s = await a.searchFields({
|
|
221
233
|
text: t.agentExecutionContext.assignedTask,
|
|
222
234
|
layerIds: t.vectorSearchLayerIds,
|
|
223
235
|
minScore: L,
|
|
224
236
|
topResults: re,
|
|
225
|
-
embeddingCache:
|
|
226
|
-
}), o =
|
|
227
|
-
const m =
|
|
237
|
+
embeddingCache: l
|
|
238
|
+
}), o = s.map(({ layerId: i, results: c }) => {
|
|
239
|
+
const m = c.map((p) => ` - ${p.name} (${p.score.toFixed(2)})`).join(`
|
|
228
240
|
`);
|
|
229
241
|
return `${d.get(i)?.layerItem.name ?? i}:
|
|
230
242
|
${m}`;
|
|
231
243
|
}).join(`
|
|
232
244
|
`);
|
|
233
|
-
let
|
|
234
|
-
return
|
|
235
|
-
${o}` :
|
|
245
|
+
let r;
|
|
246
|
+
return s.length > 0 ? r = `Vector search completed. Matching layers and fields with scores:
|
|
247
|
+
${o}` : r = `No vector search results found for score over ${L}.`, await n({ text: r }, e), {
|
|
236
248
|
...t,
|
|
237
|
-
vectorSearchFieldResults:
|
|
249
|
+
vectorSearchFieldResults: s
|
|
238
250
|
};
|
|
239
251
|
} catch (a) {
|
|
240
|
-
throw await
|
|
252
|
+
throw await n(
|
|
241
253
|
{ text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
|
|
242
254
|
e
|
|
243
255
|
), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
|
|
244
256
|
}
|
|
245
257
|
}, ie = 0.7, ne = async (t, e) => {
|
|
246
258
|
try {
|
|
247
|
-
await
|
|
259
|
+
await n(
|
|
248
260
|
{ text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
|
|
249
261
|
e
|
|
250
262
|
);
|
|
251
|
-
const a = h(e, "layerSearch"), d = h(e, "layersAndFieldsRegistry"),
|
|
263
|
+
const a = h(e, "layerSearch"), d = h(e, "layersAndFieldsRegistry"), l = h(e, "embeddingCache"), s = await a.searchLayers({
|
|
252
264
|
text: t.agentExecutionContext.assignedTask,
|
|
253
265
|
minScore: ie,
|
|
254
|
-
embeddingCache:
|
|
255
|
-
}), o =
|
|
266
|
+
embeddingCache: l
|
|
267
|
+
}), o = s.map((c) => c.id), r = s.map(({ id: c, score: m }) => `${d.get(c)?.layerItem.name ?? c} (${m.toFixed(2)})`).join(`
|
|
256
268
|
`);
|
|
257
269
|
let i;
|
|
258
270
|
return o.length > 0 ? i = `Vector search completed. Matching layers with scores:
|
|
259
|
-
${
|
|
271
|
+
${r}` : i = "Vector search completed. No matching layers found.", await n({ text: i }, e), {
|
|
260
272
|
...t,
|
|
261
273
|
vectorSearchLayerIds: o
|
|
262
274
|
};
|
|
263
275
|
} catch (a) {
|
|
264
|
-
throw await
|
|
276
|
+
throw await n(
|
|
265
277
|
{ text: `Error during vector search: ${a instanceof Error ? a.message : String(a)}` },
|
|
266
278
|
e
|
|
267
279
|
), new Error(`Vector search failed: ${a instanceof Error ? a.message : String(a)}`);
|
|
@@ -269,7 +281,7 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
|
|
|
269
281
|
}, le = (t, e) => z(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
|
|
270
282
|
t,
|
|
271
283
|
e
|
|
272
|
-
), ce = () => new b
|
|
284
|
+
), 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
285
|
"vectorSearchLayers",
|
|
274
286
|
(e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
275
287
|
).addConditionalEdges(
|
|
@@ -286,13 +298,13 @@ ${s}` : i = "Vector search completed. No matching layers found.", await c({ text
|
|
|
286
298
|
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
299
|
_Example: “How many features are there?”_
|
|
288
300
|
_Example: “What’s the average population?”_
|
|
289
|
-
_Example: “Which values are in the status field?”_`,
|
|
301
|
+
_Example: “Which values are in the status field?”_`, Re = {
|
|
290
302
|
id: "dataExploration",
|
|
291
303
|
name: "Data Exploration Agent",
|
|
292
304
|
description: de,
|
|
293
305
|
createGraph: ce,
|
|
294
|
-
workspace:
|
|
306
|
+
workspace: b
|
|
295
307
|
};
|
|
296
308
|
export {
|
|
297
|
-
|
|
309
|
+
Re as D
|
|
298
310
|
};
|