@arcgis/ai-components 5.2.0-next.12 → 5.2.0-next.14
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/LLMAgent.js +1 -0
- package/dist/cdn/{5CV7R5IS.js → 22IT5TDB.js} +2 -2
- package/dist/cdn/{EBISDZ5H.js → 4UDYY3HL.js} +1 -1
- package/dist/cdn/7PANDHIL.js +16 -0
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/{34SG44C3.js → CE6VDP2D.js} +1 -1
- package/dist/cdn/CI3QSFPS.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{YLN2BZ5J.js → E2HENO3T.js} +1 -1
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/GBYLKQIL.js +2 -0
- package/dist/cdn/GPYYAQVI.js +2 -0
- package/dist/cdn/{ERL2CB2Y.js → I2Y67HBL.js} +5 -5
- package/dist/cdn/JG2BIENI.js +3 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/K475UT3E.js +2 -0
- package/dist/cdn/{JLKGS6Y5.js → L4XF4H6V.js} +1 -1
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/PB2ODJC7.js +2 -0
- package/dist/cdn/{QCSN44H4.js → QSA4T3BU.js} +1 -1
- package/dist/cdn/{R56X6ZKR.js → QYR3NSF2.js} +3 -3
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/{T43LEBBE.js → S75VFYR4.js} +18 -18
- package/dist/cdn/SBHLUL3Q.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/XBW4MWQR.js +2 -0
- package/dist/cdn/{Z2G7MP5L.js → XU6NCSE2.js} +1 -1
- package/dist/cdn/Z7UWJ4AI.js +3 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +170 -169
- package/dist/chunks/arcgisKnowledgeGraph.js +8 -7
- package/dist/chunks/dataExplorationGraph.js +88 -76
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +161 -159
- package/dist/chunks/helpGraph.js +3 -2
- package/dist/chunks/layerStylingGraph.js +1 -0
- package/dist/chunks/navigationGraph.js +3 -2
- package/dist/chunks/orchestrator.js +108 -107
- package/dist/chunks/toolCallResponse.js +10 -9
- package/dist/components/arcgis-assistant/customElement.js +136 -124
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +3 -2
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +4 -3
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/cdn/24QNMEFG.js +0 -2
- package/dist/cdn/3NBDVZ2I.js +0 -2
- package/dist/cdn/53NTYC4I.js +0 -2
- package/dist/cdn/AZGGTNA3.js +0 -2
- package/dist/cdn/B7WJFBOZ.js +0 -2
- package/dist/cdn/DZ2QWNUA.js +0 -3
- package/dist/cdn/F6QHMKF5.js +0 -2
- package/dist/cdn/H2CHHGGH.js +0 -2
- package/dist/cdn/HWKDNS4K.js +0 -4
- package/dist/cdn/IMQ4TVHF.js +0 -16
- package/dist/cdn/IRZDTYO2.js +0 -2
- package/dist/cdn/KHXUWZHB.js +0 -2
- package/dist/cdn/LIFK3QSD.js +0 -2
- package/dist/cdn/O3EN27N5.js +0 -2
- package/dist/cdn/PBO6FZN6.js +0 -2
- package/dist/cdn/Q3ZW4FYA.js +0 -3
- package/dist/cdn/UPEEHMSY.js +0 -2
- package/dist/cdn/WAIFKDR3.js +0 -2
- package/dist/cdn/XON27U6U.js +0 -2
- package/dist/cdn/YUKR4AZW.js +0 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { StateGraph as f, START as x, END as h, Command as k } from "@langchain/langgraph/web";
|
|
3
|
-
import { a as b, c as _, b as K, d as A, e as T, s as v, q
|
|
3
|
+
import { a as b, c as _, b as K, d as A, e as T, s as v, q, g as u, h as M, t as c, r as S, i as C, G as E, j as m } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
|
+
import "@arcgis/toolkit/string";
|
|
6
7
|
import { h as G, e as N } from "./generateLayerDescriptions.js";
|
|
7
8
|
import { AIMessage as R } from "@langchain/core/messages";
|
|
8
9
|
import "@langchain/core/callbacks/dispatch/web";
|
|
@@ -21,10 +22,10 @@ const w = [
|
|
|
21
22
|
A,
|
|
22
23
|
T,
|
|
23
24
|
v,
|
|
24
|
-
|
|
25
|
+
q
|
|
25
26
|
];
|
|
26
27
|
async function z(e, a) {
|
|
27
|
-
const i = await u("arcgis_knowledge_tool_prompt"), o =
|
|
28
|
+
const i = await u("arcgis_knowledge_tool_prompt"), o = M(a), n = {
|
|
28
29
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
29
30
|
userRequest: e.agentExecutionContext.userRequest,
|
|
30
31
|
priorSteps: e.agentExecutionContext.priorSteps,
|
|
@@ -126,7 +127,7 @@ async function I(e, a) {
|
|
|
126
127
|
}
|
|
127
128
|
const V = (e, a) => (
|
|
128
129
|
//agent services (ex: embeddingsWorker) would go in the array below, if required.
|
|
129
|
-
|
|
130
|
+
S([], "ArcgisKnowledge Agent")(e, a)
|
|
130
131
|
);
|
|
131
132
|
async function j(e, a) {
|
|
132
133
|
const o = (e.arcgisKnowledgeToolResult ?? []).map((d) => ({
|
|
@@ -152,7 +153,7 @@ async function j(e, a) {
|
|
|
152
153
|
};
|
|
153
154
|
}
|
|
154
155
|
function g(e) {
|
|
155
|
-
return async (a, i) => i?.
|
|
156
|
+
return async (a, i) => i?.signal?.aborted ? (await p({ text: "Knowledge Agent execution cancelled" }, i), new k({
|
|
156
157
|
goto: h,
|
|
157
158
|
update: {
|
|
158
159
|
outputMessage: "Knowledge Agent execution cancelled",
|
|
@@ -199,7 +200,7 @@ _example: "Discover and add all the relationships originating at 'Entity E' to t
|
|
|
199
200
|
_example: "Show me all entities with a name similar to 'Smith' and add them to the link chart"_
|
|
200
201
|
_example: "Find reports in my graph that have a title similar to 'Quarterly Earnings'"_
|
|
201
202
|
_example: "Find John Smith and all people he has made phone calls to in the last year"_
|
|
202
|
-
_example: "What is the average age of all people who work for Esri?"_`,
|
|
203
|
+
_example: "What is the average age of all people who work for Esri?"_`, ie = {
|
|
203
204
|
id: "arcgisKnowledge",
|
|
204
205
|
name: "ArcgisKnowledge Agent",
|
|
205
206
|
description: P,
|
|
@@ -207,5 +208,5 @@ _example: "What is the average age of all people who work for Esri?"_`, re = {
|
|
|
207
208
|
workspace: m
|
|
208
209
|
};
|
|
209
210
|
export {
|
|
210
|
-
|
|
211
|
+
ie as A
|
|
211
212
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
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
|
|
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 _, 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";
|
|
8
9
|
import { s as n } from "./index.js";
|
|
9
10
|
import "@langchain/openai";
|
|
10
11
|
import "@arcgis/core/config.js";
|
|
@@ -12,8 +13,8 @@ import "@arcgis/core/core/reactiveUtils.js";
|
|
|
12
13
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
13
14
|
import "@arcgis/core/request.js";
|
|
14
15
|
import "@langchain/core/prompts";
|
|
15
|
-
import { h as
|
|
16
|
-
import { ToolNode as
|
|
16
|
+
import { h as b } from "./toolCallResponse.js";
|
|
17
|
+
import { ToolNode as j } from "@langchain/langgraph/prebuilt";
|
|
17
18
|
import G from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
18
19
|
import U from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
19
20
|
const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e), t), B = async (t, e) => {
|
|
@@ -21,7 +22,7 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
21
22
|
const d = await T("data_explore_filter_prompt");
|
|
22
23
|
if (!e?.configurable)
|
|
23
24
|
throw new Error("config.configurable is required for layer filter tools");
|
|
24
|
-
const { userTimezone: l, userTimezoneOffset: s } = R(),
|
|
25
|
+
const { userTimezone: l, userTimezoneOffset: s } = R(), r = {
|
|
25
26
|
layerFieldInfo: t.layerFieldInfo,
|
|
26
27
|
userTimezone: l,
|
|
27
28
|
userTimezoneOffset: s,
|
|
@@ -29,59 +30,70 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
29
30
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
30
31
|
userRequest: t.agentExecutionContext.userRequest,
|
|
31
32
|
priorSteps: t.agentExecutionContext.priorSteps
|
|
32
|
-
},
|
|
33
|
+
}, o = await $({
|
|
33
34
|
promptText: d,
|
|
34
35
|
modelTier: "advanced",
|
|
35
36
|
config: e,
|
|
36
37
|
messages: t.dataExplorationMessages,
|
|
37
|
-
inputVariables:
|
|
38
|
+
inputVariables: r,
|
|
38
39
|
tools: C
|
|
39
|
-
}), i = [...t.dataExplorationMessages,
|
|
40
|
-
if (!((
|
|
40
|
+
}), i = [...t.dataExplorationMessages, o];
|
|
41
|
+
if (!((o.tool_calls?.length ?? 0) > 0))
|
|
41
42
|
return await n({ text: "LLM determined no filter changes needed" }, e), {
|
|
42
43
|
...t,
|
|
43
44
|
dataExplorationMessages: i
|
|
44
45
|
// Don't overwrite outputMessage if query already set it
|
|
45
46
|
};
|
|
46
|
-
const m = i,
|
|
47
|
-
return await
|
|
47
|
+
const m = i, g = o.content.toString();
|
|
48
|
+
return await b(o, e), { ...t, dataExplorationMessages: m, outputMessage: g };
|
|
48
49
|
}, H = async (t, e) => {
|
|
49
50
|
await n({ text: "Requesting LLM for layer query results" }, e);
|
|
50
51
|
const d = await T("data_explore_query_prompt");
|
|
51
52
|
if (!e?.configurable)
|
|
52
53
|
throw new Error("config.configurable is required for layer query tools");
|
|
53
|
-
const { userTimezone: l, userTimezoneOffset: s } = R(), r = t.agentExecutionContext.sharedState
|
|
54
|
+
const { userTimezone: l, userTimezoneOffset: s } = R(), r = t.agentExecutionContext.sharedState, o = r.lastNavigatedFeatures?.value, i = r.lastResolvedLocation?.value;
|
|
54
55
|
let c = "none";
|
|
55
|
-
if (
|
|
56
|
+
if (o != null)
|
|
56
57
|
try {
|
|
57
|
-
c = JSON.stringify(
|
|
58
|
+
c = JSON.stringify(o);
|
|
58
59
|
} catch {
|
|
59
60
|
c = "none";
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
let m = "none";
|
|
63
|
+
if (i != null)
|
|
64
|
+
try {
|
|
65
|
+
m = JSON.stringify({
|
|
66
|
+
address: i.address,
|
|
67
|
+
location: i.location
|
|
68
|
+
});
|
|
69
|
+
} catch {
|
|
70
|
+
m = "none";
|
|
71
|
+
}
|
|
72
|
+
const g = {
|
|
62
73
|
layerFieldInfo: t.layerFieldInfo,
|
|
63
74
|
userTimezone: l,
|
|
64
75
|
userTimezoneOffset: s,
|
|
65
76
|
assignedTask: t.agentExecutionContext.assignedTask,
|
|
66
77
|
userRequest: t.agentExecutionContext.userRequest,
|
|
67
78
|
priorSteps: t.agentExecutionContext.priorSteps,
|
|
68
|
-
lastNavigatedFeatures: c
|
|
69
|
-
|
|
79
|
+
lastNavigatedFeatures: c,
|
|
80
|
+
lastResolvedLocation: m
|
|
81
|
+
}, y = await $({
|
|
70
82
|
promptText: d,
|
|
71
83
|
modelTier: "advanced",
|
|
72
84
|
config: e,
|
|
73
85
|
messages: t.dataExplorationMessages,
|
|
74
|
-
inputVariables:
|
|
86
|
+
inputVariables: g,
|
|
75
87
|
tools: V
|
|
76
|
-
}),
|
|
77
|
-
return await
|
|
88
|
+
}), h = (y.tool_calls?.length ?? 0) > 0, p = y.content.toString();
|
|
89
|
+
return await b(y, e), {
|
|
78
90
|
...t,
|
|
79
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
91
|
+
dataExplorationMessages: [...t.dataExplorationMessages, y],
|
|
80
92
|
// Only emit output here when no tools are being called.
|
|
81
93
|
// For tool-calling flows, downstream summarizer nodes provide the final user-facing message.
|
|
82
|
-
...
|
|
94
|
+
...h ? {} : { outputMessage: p },
|
|
83
95
|
status: "success",
|
|
84
|
-
summary:
|
|
96
|
+
summary: p && !h ? N(p) : "Query planning completed."
|
|
85
97
|
};
|
|
86
98
|
}, J = async (t, e) => {
|
|
87
99
|
try {
|
|
@@ -97,15 +109,15 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
97
109
|
config: e,
|
|
98
110
|
messages: t.dataExplorationMessages,
|
|
99
111
|
inputVariables: l
|
|
100
|
-
}),
|
|
101
|
-
await n({ text: `Received response from LLM: ${
|
|
102
|
-
const i =
|
|
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;
|
|
103
115
|
return {
|
|
104
116
|
...t,
|
|
105
117
|
outputMessage: i,
|
|
106
118
|
status: "success",
|
|
107
119
|
summary: i ? N(i) : "Summary generated.",
|
|
108
|
-
dataExplorationMessages: [...t.dataExplorationMessages,
|
|
120
|
+
dataExplorationMessages: [...t.dataExplorationMessages, o]
|
|
109
121
|
};
|
|
110
122
|
} catch (a) {
|
|
111
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)}`);
|
|
@@ -113,11 +125,11 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
113
125
|
};
|
|
114
126
|
async function K(t, e) {
|
|
115
127
|
if ((t.queryResponse ?? []).some((s) => {
|
|
116
|
-
const
|
|
117
|
-
return typeof
|
|
128
|
+
const r = s.details;
|
|
129
|
+
return typeof r == "object" && r !== null && "error" in r;
|
|
118
130
|
}))
|
|
119
131
|
return await n({ text: "Skipping layer filter tool because query response contains an error." }, e), { ...t };
|
|
120
|
-
const l = await new
|
|
132
|
+
const l = await new j(C, { handleToolErrors: !1 }).invoke(
|
|
121
133
|
{
|
|
122
134
|
messages: t.dataExplorationMessages
|
|
123
135
|
},
|
|
@@ -133,14 +145,14 @@ const X = 10, Y = ["string", "small-integer", "integer"], Z = async (t, e, { inc
|
|
|
133
145
|
try {
|
|
134
146
|
if (e.type !== "geometry" && e.type !== "oid" && e.type !== "global-id") {
|
|
135
147
|
a && (l = await G({ layer: t, field: e.name }));
|
|
136
|
-
const
|
|
137
|
-
d && (Y.includes(e.type) ||
|
|
138
|
-
...
|
|
139
|
-
value:
|
|
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
|
|
140
152
|
}))));
|
|
141
153
|
}
|
|
142
|
-
} catch (
|
|
143
|
-
console.error(`Error fetching statistics for field ${e.name}:`,
|
|
154
|
+
} catch (r) {
|
|
155
|
+
console.error(`Error fetching statistics for field ${e.name}:`, r);
|
|
144
156
|
}
|
|
145
157
|
return {
|
|
146
158
|
summaryStatistics: l,
|
|
@@ -151,36 +163,36 @@ function ee(t, e) {
|
|
|
151
163
|
return ["string", "small-integer", "integer"].includes(t) || e === "coded-value";
|
|
152
164
|
}
|
|
153
165
|
async function te(t, e, a, d = !0) {
|
|
154
|
-
const l = [], s = [],
|
|
155
|
-
for (const
|
|
156
|
-
let i = function(
|
|
157
|
-
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;
|
|
158
170
|
return u ? [
|
|
159
171
|
u.name && `Name: ${u.name}`,
|
|
160
172
|
u.title && `Title: ${u.title}`,
|
|
161
173
|
u.description && `Description: ${u.description}`
|
|
162
|
-
].filter(Boolean).join(" | ") :
|
|
174
|
+
].filter(Boolean).join(" | ") : p;
|
|
163
175
|
};
|
|
164
|
-
const { layerId: c, results: m } =
|
|
165
|
-
if (!
|
|
176
|
+
const { layerId: c, results: m } = o, g = a.map?.allLayers.find((p) => p.id === c), y = e.get(c)?.fieldRegistry;
|
|
177
|
+
if (!y)
|
|
166
178
|
continue;
|
|
167
|
-
let
|
|
168
|
-
|
|
179
|
+
let h = l.find((p) => p.layerId === c);
|
|
180
|
+
h || (h = {
|
|
169
181
|
layerId: c,
|
|
170
182
|
layerSummary: i(c),
|
|
171
183
|
fieldInfos: []
|
|
172
|
-
}, l.push(
|
|
173
|
-
for (const
|
|
174
|
-
const u =
|
|
184
|
+
}, l.push(h));
|
|
185
|
+
for (const p of m) {
|
|
186
|
+
const u = y.get(p.name);
|
|
175
187
|
if (!u)
|
|
176
188
|
continue;
|
|
177
189
|
const x = u.statistics, E = d && !x?.summaryStatistics, w = ee(u.type, u.domain?.type) && !x?.uniqueValues, q = E || w;
|
|
178
|
-
if (
|
|
190
|
+
if (r.push({
|
|
179
191
|
layerId: c,
|
|
180
192
|
fieldName: u.name,
|
|
181
193
|
didFetchStatistics: q
|
|
182
194
|
}), q) {
|
|
183
|
-
const A = Z(
|
|
195
|
+
const A = Z(g, u, {
|
|
184
196
|
includeSummaryStatistics: E,
|
|
185
197
|
includeUniqueValues: w
|
|
186
198
|
}).then((F) => {
|
|
@@ -188,31 +200,31 @@ async function te(t, e, a, d = !0) {
|
|
|
188
200
|
summaryStatistics: x?.summaryStatistics ?? null,
|
|
189
201
|
uniqueValues: x?.uniqueValues ?? null
|
|
190
202
|
};
|
|
191
|
-
E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues),
|
|
203
|
+
E && (S.summaryStatistics = F.summaryStatistics), w && (S.uniqueValues = F.uniqueValues), y.set(u.name, { ...u, statistics: S }), u.statistics = S;
|
|
192
204
|
});
|
|
193
205
|
s.push(A);
|
|
194
206
|
}
|
|
195
|
-
|
|
207
|
+
h.fieldInfos.push(u);
|
|
196
208
|
}
|
|
197
209
|
}
|
|
198
210
|
return await Promise.all(s), {
|
|
199
211
|
layerFieldInfo: l,
|
|
200
212
|
didFetchStatistics: s.length > 0,
|
|
201
|
-
fieldStatisticsFetchStatus:
|
|
213
|
+
fieldStatisticsFetchStatus: r
|
|
202
214
|
};
|
|
203
215
|
}
|
|
204
|
-
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;
|
|
205
217
|
function ae(t, e) {
|
|
206
|
-
return
|
|
218
|
+
return L.test(t) || L.test(e);
|
|
207
219
|
}
|
|
208
220
|
const se = async (t, e) => {
|
|
209
221
|
try {
|
|
210
222
|
await n({ text: "Preparing field information for vector search results" }, e);
|
|
211
|
-
const a =
|
|
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(
|
|
212
224
|
t.vectorSearchFieldResults,
|
|
213
225
|
a,
|
|
214
226
|
d,
|
|
215
|
-
|
|
227
|
+
r
|
|
216
228
|
);
|
|
217
229
|
i ? await n({ text: "Statistics fetched" }, e) : await n({ text: "Statistics skipped" }, e);
|
|
218
230
|
for (const m of c)
|
|
@@ -222,29 +234,29 @@ const se = async (t, e) => {
|
|
|
222
234
|
},
|
|
223
235
|
e
|
|
224
236
|
);
|
|
225
|
-
return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo:
|
|
237
|
+
return await n({ text: "Field information prepared" }, e), { ...t, layerFieldInfo: o };
|
|
226
238
|
} catch (a) {
|
|
227
239
|
throw await n({ text: "Error during fetching statistics" }, e), new Error(`Error during fetching statistics: ${a instanceof Error ? a.message : String(a)}`);
|
|
228
240
|
}
|
|
229
|
-
},
|
|
241
|
+
}, M = 0.7, re = 10, oe = async (t, e) => {
|
|
230
242
|
try {
|
|
231
243
|
await n({ text: "Similarity search to find fields" }, e);
|
|
232
|
-
const a =
|
|
244
|
+
const a = f(e, "fieldSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchFields({
|
|
233
245
|
text: t.agentExecutionContext.assignedTask,
|
|
234
246
|
layerIds: t.vectorSearchLayerIds,
|
|
235
|
-
minScore:
|
|
247
|
+
minScore: M,
|
|
236
248
|
topResults: re,
|
|
237
249
|
embeddingCache: l
|
|
238
|
-
}),
|
|
239
|
-
const m = c.map((
|
|
250
|
+
}), r = s.map(({ layerId: i, results: c }) => {
|
|
251
|
+
const m = c.map((g) => ` - ${g.name} (${g.score.toFixed(2)})`).join(`
|
|
240
252
|
`);
|
|
241
253
|
return `${d.get(i)?.layerItem.name ?? i}:
|
|
242
254
|
${m}`;
|
|
243
255
|
}).join(`
|
|
244
256
|
`);
|
|
245
|
-
let
|
|
246
|
-
return s.length > 0 ?
|
|
247
|
-
${
|
|
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), {
|
|
248
260
|
...t,
|
|
249
261
|
vectorSearchFieldResults: s
|
|
250
262
|
};
|
|
@@ -260,17 +272,17 @@ ${o}` : r = `No vector search results found for score over ${L}.`, await n({ tex
|
|
|
260
272
|
{ text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
|
|
261
273
|
e
|
|
262
274
|
);
|
|
263
|
-
const a =
|
|
275
|
+
const a = f(e, "layerSearch"), d = f(e, "layersAndFieldsRegistry"), l = f(e, "embeddingCache"), s = await a.searchLayers({
|
|
264
276
|
text: t.agentExecutionContext.assignedTask,
|
|
265
277
|
minScore: ie,
|
|
266
278
|
embeddingCache: l
|
|
267
|
-
}),
|
|
279
|
+
}), r = s.map((c) => c.id), o = s.map(({ id: c, score: m }) => `${d.get(c)?.layerItem.name ?? c} (${m.toFixed(2)})`).join(`
|
|
268
280
|
`);
|
|
269
281
|
let i;
|
|
270
|
-
return
|
|
271
|
-
${
|
|
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), {
|
|
272
284
|
...t,
|
|
273
|
-
vectorSearchLayerIds:
|
|
285
|
+
vectorSearchLayerIds: r
|
|
274
286
|
};
|
|
275
287
|
} catch (a) {
|
|
276
288
|
throw await n(
|
|
@@ -281,7 +293,7 @@ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text
|
|
|
281
293
|
}, le = (t, e) => z(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
|
|
282
294
|
t,
|
|
283
295
|
e
|
|
284
|
-
), ce = () => new I(
|
|
296
|
+
), ce = () => new I(_).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(
|
|
285
297
|
"vectorSearchLayers",
|
|
286
298
|
(e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
287
299
|
).addConditionalEdges(
|
|
@@ -298,13 +310,13 @@ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text
|
|
|
298
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.
|
|
299
311
|
_Example: “How many features are there?”_
|
|
300
312
|
_Example: “What’s the average population?”_
|
|
301
|
-
_Example: “Which values are in the status field?”_`,
|
|
313
|
+
_Example: “Which values are in the status field?”_`, Ce = {
|
|
302
314
|
id: "dataExploration",
|
|
303
315
|
name: "Data Exploration Agent",
|
|
304
316
|
description: de,
|
|
305
317
|
createGraph: ce,
|
|
306
|
-
workspace:
|
|
318
|
+
workspace: _
|
|
307
319
|
};
|
|
308
320
|
export {
|
|
309
|
-
|
|
321
|
+
Ce as D
|
|
310
322
|
};
|
|
@@ -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
|
|