@arcgis/ai-components 5.2.0-next.0 → 5.2.0-next.2
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/cdn/{6R6AY3D3.js → 4HU7735A.js} +1 -1
- package/dist/cdn/{METXWS7V.js → FHVXO2WG.js} +13 -13
- package/dist/cdn/{6MAINSY5.js → FL4W4VYN.js} +0 -1
- package/dist/cdn/{N2VQD46V.js → GSEPHN3A.js} +1 -1
- package/dist/cdn/{Y67XAMT4.js → JY6LLOUJ.js} +1 -1
- package/dist/cdn/{FB5DRKEB.js → MDVYQQUG.js} +1 -1
- package/dist/cdn/{EF453FJ2.js → ON2V5XI2.js} +1 -1
- package/dist/cdn/{QDO2AO53.js → S6W6HV4T.js} +1 -1
- package/dist/cdn/V5YEZSRY.js +16 -0
- package/dist/cdn/{GM3QP65I.js → X2ZDYHCG.js} +18 -5
- package/dist/cdn/{SZOVY2QU.js → YY2SBO3V.js} +1 -1
- package/dist/cdn/{LBVX2JYG.js → ZLXN7NMF.js} +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +107 -97
- package/dist/chunks/dataExplorationGraph.js +95 -86
- package/dist/chunks/data_explore_query_prompt.js +18 -5
- package/dist/chunks/intent_prompt.js +0 -1
- package/dist/chunks/summarize_query_response_prompt.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 +4 -4
- package/dist/cdn/U3QQW6VA.js +0 -16
package/dist/chunks/adapter.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import ce from "@arcgis/core/identity/IdentityManager.js";
|
|
3
|
-
import
|
|
3
|
+
import k from "@arcgis/core/portal/Portal.js";
|
|
4
4
|
import { Annotation as b, messagesStateReducer as me } from "@langchain/langgraph/web";
|
|
5
|
-
import { n as Ne, o as x, k as U, s as
|
|
5
|
+
import { n as Ne, o as x, k as U, s as S, i as ze } from "./generateLayerDescriptions.js";
|
|
6
6
|
import "@langchain/core/messages";
|
|
7
7
|
import "@langchain/core/callbacks/dispatch/web";
|
|
8
8
|
import "@langchain/openai";
|
|
@@ -70,7 +70,7 @@ const L = (e, t) => t ?? e, Tn = b.Root({
|
|
|
70
70
|
})
|
|
71
71
|
});
|
|
72
72
|
async function yt(e, t) {
|
|
73
|
-
const o =
|
|
73
|
+
const o = k.getDefault().helperServices, a = o.geocode.find((h) => h.name === "ArcGIS World Geocoding Service") ?? o.geocode[0];
|
|
74
74
|
if (!a)
|
|
75
75
|
throw new Error("No geocoding service found in helperServices.");
|
|
76
76
|
const n = a.url, s = `${J.assetsPath?.endsWith("/") ? J.assetsPath : `${J.assetsPath}/`}esri/images/search/search-symbol-32.png`, u = (await Ae(n, {
|
|
@@ -114,7 +114,7 @@ async function gt({ address: e }, t) {
|
|
|
114
114
|
}
|
|
115
115
|
const wt = i.object({
|
|
116
116
|
address: i.string().describe("The full address or place name to locate.")
|
|
117
|
-
}),
|
|
117
|
+
}), vn = f(gt, {
|
|
118
118
|
name: "goToAddress",
|
|
119
119
|
description: "Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",
|
|
120
120
|
schema: wt
|
|
@@ -135,35 +135,45 @@ async function Tt({ bookmarkName: e }, t) {
|
|
|
135
135
|
const { mapView: r } = $(t);
|
|
136
136
|
return await Promise.resolve(bt(e, r));
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const vt = C.object({
|
|
139
139
|
bookmarkName: C.string().describe("The name of the bookmark to navigate to.")
|
|
140
|
-
}),
|
|
140
|
+
}), Sn = f(Tt, {
|
|
141
141
|
name: "goToBookmark",
|
|
142
142
|
description: "Go to the extent of the bookmark with the given name.",
|
|
143
|
-
schema:
|
|
143
|
+
schema: vt
|
|
144
144
|
});
|
|
145
|
-
async function
|
|
146
|
-
const o = r.map?.allLayers.find((
|
|
145
|
+
async function St(e, t, r) {
|
|
146
|
+
const o = r.map?.allLayers.find((s) => s.id === e);
|
|
147
147
|
if (!o)
|
|
148
148
|
return { text: `Error: Layer with id ${e} not found` };
|
|
149
|
-
const a = o.createQuery();
|
|
150
|
-
|
|
149
|
+
const a = t?.trim() ? t : "1=1", n = o.createQuery();
|
|
150
|
+
n.where = a;
|
|
151
151
|
try {
|
|
152
|
-
const { extent:
|
|
153
|
-
if (
|
|
154
|
-
return { text: `No features found in ${o.title} matching: ${
|
|
155
|
-
if (
|
|
156
|
-
await r.goTo(
|
|
152
|
+
const { extent: s, count: c } = await o.queryExtent(n);
|
|
153
|
+
if (c === 0)
|
|
154
|
+
return { text: `No features found in ${o.title} matching: ${a}`, where: a };
|
|
155
|
+
if (s)
|
|
156
|
+
await r.goTo(s);
|
|
157
157
|
else
|
|
158
|
-
return { text: `Error: Unable to determine extent for ${o.title}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
return { text: `Error: Unable to determine extent for ${o.title}`, where: a };
|
|
159
|
+
const u = {
|
|
160
|
+
layerId: e,
|
|
161
|
+
layerTitle: o.title ?? e,
|
|
162
|
+
where: a,
|
|
163
|
+
count: c
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
text: `Successfully zoomed to ${c} feature(s) in ${o.title} matching: ${a}`,
|
|
167
|
+
where: a,
|
|
168
|
+
sharedStatePatch: { lastNavigatedFeatures: { value: u } }
|
|
169
|
+
};
|
|
170
|
+
} catch (s) {
|
|
171
|
+
return console.error("Error in goToFeatures:", s), { text: `Error: ${s instanceof Error ? s.message : "Unknown error"}`, where: a };
|
|
162
172
|
}
|
|
163
173
|
}
|
|
164
174
|
async function xt({ layerId: e, where: t }, r) {
|
|
165
175
|
const { mapView: o } = $(r);
|
|
166
|
-
return await
|
|
176
|
+
return await St(e, t, o);
|
|
167
177
|
}
|
|
168
178
|
const Rt = C.object({
|
|
169
179
|
layerId: C.string().describe("The layerId of the layer to zoom to."),
|
|
@@ -200,14 +210,14 @@ async function It(e) {
|
|
|
200
210
|
throw new Error("Initial extent is undefined");
|
|
201
211
|
return { text: "Successfully zoomed to home extent" };
|
|
202
212
|
}
|
|
203
|
-
async function
|
|
213
|
+
async function Ft(e, t) {
|
|
204
214
|
const { mapView: r } = $(t);
|
|
205
215
|
return await It(r);
|
|
206
216
|
}
|
|
207
|
-
const
|
|
217
|
+
const kt = i.object({}), $n = f(Ft, {
|
|
208
218
|
name: "goToHomeExtent",
|
|
209
219
|
description: "Go to the initial web map view extent",
|
|
210
|
-
schema:
|
|
220
|
+
schema: kt
|
|
211
221
|
});
|
|
212
222
|
async function Nt(e, t) {
|
|
213
223
|
await t.when();
|
|
@@ -285,7 +295,7 @@ async function Mt({ zoom: e }, t) {
|
|
|
285
295
|
}
|
|
286
296
|
const Qt = i.object({
|
|
287
297
|
zoom: i.number().min(1).max(20).describe("The zoom level of the view to go to.")
|
|
288
|
-
}),
|
|
298
|
+
}), Fn = f(Mt, {
|
|
289
299
|
name: "goToZoom",
|
|
290
300
|
description: 'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',
|
|
291
301
|
schema: Qt
|
|
@@ -320,7 +330,7 @@ const _t = (e, t = 300) => {
|
|
|
320
330
|
if (o == null)
|
|
321
331
|
throw new Error(`${t} missing in config.configurable.services`);
|
|
322
332
|
return o;
|
|
323
|
-
},
|
|
333
|
+
}, kn = (e, t) => (r, o) => {
|
|
324
334
|
const a = o?.configurable?.services;
|
|
325
335
|
for (const n of e)
|
|
326
336
|
if (!a?.[n])
|
|
@@ -809,7 +819,7 @@ Example: Create a heatmap
|
|
|
809
819
|
Fields: This typically requires zero or one field of type number.`,
|
|
810
820
|
schema: Tr
|
|
811
821
|
});
|
|
812
|
-
function
|
|
822
|
+
function vr(e) {
|
|
813
823
|
const { fields: t, layer: r, view: o, styleName: a, colorSchemeTags: n } = e;
|
|
814
824
|
let s;
|
|
815
825
|
return n && (s = He({
|
|
@@ -826,7 +836,7 @@ function Sr(e) {
|
|
|
826
836
|
predominanceScheme: s
|
|
827
837
|
};
|
|
828
838
|
}
|
|
829
|
-
async function
|
|
839
|
+
async function Sr(e) {
|
|
830
840
|
return await Be(e);
|
|
831
841
|
}
|
|
832
842
|
async function xr({
|
|
@@ -848,7 +858,7 @@ async function xr({
|
|
|
848
858
|
colorSchemeTags: a
|
|
849
859
|
};
|
|
850
860
|
try {
|
|
851
|
-
const d =
|
|
861
|
+
const d = vr(l), p = await Sr(d);
|
|
852
862
|
return c.renderer = p.renderer, c.visible = !0, `Predominance renderer applied to layer: ${c.title ?? c.id} using fields ${o.join(", ")}`;
|
|
853
863
|
} catch (d) {
|
|
854
864
|
return `Error applying predominance renderer: ${d instanceof Error ? d.message : String(d)}`;
|
|
@@ -938,7 +948,7 @@ async function Ir({
|
|
|
938
948
|
return `Error applying relationship renderer: ${u instanceof Error ? u.message : String(u)}`;
|
|
939
949
|
}
|
|
940
950
|
}
|
|
941
|
-
async function
|
|
951
|
+
async function Fr({
|
|
942
952
|
layerId: e,
|
|
943
953
|
fields: t,
|
|
944
954
|
colorSchemes: r
|
|
@@ -952,18 +962,18 @@ async function kr({
|
|
|
952
962
|
colorSchemes: r
|
|
953
963
|
});
|
|
954
964
|
}
|
|
955
|
-
const
|
|
965
|
+
const kr = i.object({
|
|
956
966
|
layerId: i.string().describe("The id of the layer to apply the relationship renderer to"),
|
|
957
967
|
fields: i.array(i.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),
|
|
958
968
|
colorSchemes: i.array(i.string()).optional().describe("Optional color scheme tags to use")
|
|
959
|
-
}), jn = f(
|
|
969
|
+
}), jn = f(Fr, {
|
|
960
970
|
name: "relationship",
|
|
961
971
|
description: `Label: Relationship
|
|
962
972
|
Description: Overlays two color ramps to represent the relationship between two numeric attributes.
|
|
963
973
|
Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
|
|
964
974
|
Example: Show the relationship between tree height and carbon storage
|
|
965
975
|
Fields: This style requires two number fields.`,
|
|
966
|
-
schema:
|
|
976
|
+
schema: kr
|
|
967
977
|
});
|
|
968
978
|
function Nr(e) {
|
|
969
979
|
const { fields: t, layer: r, view: o, theme: a } = e, n = t[0];
|
|
@@ -1471,15 +1481,15 @@ const K = async (e, t) => {
|
|
|
1471
1481
|
} catch {
|
|
1472
1482
|
return e;
|
|
1473
1483
|
}
|
|
1474
|
-
}, Te = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t,
|
|
1484
|
+
}, Te = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, ve = (e, t, r, o, a) => {
|
|
1475
1485
|
if (r == null)
|
|
1476
1486
|
return r;
|
|
1477
1487
|
const s = e.getFieldConfiguration?.(t)?.fieldFormat;
|
|
1478
1488
|
return s?.type === "number" ? ho(r, s) : s?.type === "date-time" ? mo(r, s, a) : lo(r, o, a);
|
|
1479
1489
|
}, yo = (e, t, r, o) => {
|
|
1480
1490
|
const a = e.fieldsIndex?.get(t), n = be(t, r, e) ?? r;
|
|
1481
|
-
return
|
|
1482
|
-
}, fo = (e, t) => Te(e, t),
|
|
1491
|
+
return ve(e, t, n, a?.type, o);
|
|
1492
|
+
}, fo = (e, t) => Te(e, t), Se = (e, t, r) => {
|
|
1483
1493
|
const o = e.objectIdField, a = t.features.map(
|
|
1484
1494
|
(s) => s.attributes[o]
|
|
1485
1495
|
), n = t.features.map((s) => {
|
|
@@ -1493,7 +1503,7 @@ const K = async (e, t) => {
|
|
|
1493
1503
|
return;
|
|
1494
1504
|
}
|
|
1495
1505
|
const p = be(l.name, d, e) ?? d, h = Te(e, l.name);
|
|
1496
|
-
u[h] =
|
|
1506
|
+
u[h] = ve(e, l.name, p, l.type, r);
|
|
1497
1507
|
}), u;
|
|
1498
1508
|
});
|
|
1499
1509
|
return { objectIds: a, attributes: n };
|
|
@@ -1524,7 +1534,7 @@ const To = i.object({
|
|
|
1524
1534
|
query: i.object({
|
|
1525
1535
|
where: i.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")
|
|
1526
1536
|
})
|
|
1527
|
-
}),
|
|
1537
|
+
}), vo = f(bo, {
|
|
1528
1538
|
name: "getAttribute",
|
|
1529
1539
|
description: "Returns an attribute value for a given feature.",
|
|
1530
1540
|
schema: To
|
|
@@ -1533,8 +1543,8 @@ function V(e, t) {
|
|
|
1533
1543
|
let r = e ?? "";
|
|
1534
1544
|
return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
|
|
1535
1545
|
}
|
|
1536
|
-
const
|
|
1537
|
-
const { targetLayer: t, fieldName: r, statisticType: o, mapView: a, layersAndFieldsRegistry: n, geometryFilter: s } = e, c = a.map?.allLayers.find((
|
|
1546
|
+
const So = async (e) => {
|
|
1547
|
+
const { targetLayer: t, fieldName: r, statisticType: o, mapView: a, layersAndFieldsRegistry: n, geometryFilter: s } = e, c = a.map?.allLayers.find((v) => v.id === t.layerId);
|
|
1538
1548
|
if (!c)
|
|
1539
1549
|
throw new Error(`Layer '${t.layerId}' not found.`);
|
|
1540
1550
|
const u = await a.whenLayerView(c), d = n.get(t.layerId)?.fieldRegistry.get(r), p = d?.alias;
|
|
@@ -1542,10 +1552,10 @@ const vo = async (e) => {
|
|
|
1542
1552
|
throw new Error(`Field '${r}' not found.`);
|
|
1543
1553
|
let h, m;
|
|
1544
1554
|
if (s) {
|
|
1545
|
-
const
|
|
1546
|
-
if ("error" in
|
|
1547
|
-
throw new Error(
|
|
1548
|
-
if (!
|
|
1555
|
+
const v = await K(s, a);
|
|
1556
|
+
if ("error" in v)
|
|
1557
|
+
throw new Error(v.error);
|
|
1558
|
+
if (!v.geometry)
|
|
1549
1559
|
throw P(s) ? new Error(`No features found matching: ${s.where}`) : new Error("Failed to create geometry");
|
|
1550
1560
|
if (P(s)) {
|
|
1551
1561
|
const O = a.map?.allLayers.find((A) => A.id === s.layerId);
|
|
@@ -1564,7 +1574,7 @@ const vo = async (e) => {
|
|
|
1564
1574
|
applied: !0
|
|
1565
1575
|
});
|
|
1566
1576
|
m = new fe({
|
|
1567
|
-
geometry:
|
|
1577
|
+
geometry: v.geometry,
|
|
1568
1578
|
distance: s.distance,
|
|
1569
1579
|
units: s.units,
|
|
1570
1580
|
spatialRelationship: "intersects"
|
|
@@ -1575,7 +1585,7 @@ const vo = async (e) => {
|
|
|
1575
1585
|
const T = 10;
|
|
1576
1586
|
if (d.type !== "geometry" && d.type !== "oid" && d.type !== "global-id")
|
|
1577
1587
|
try {
|
|
1578
|
-
const
|
|
1588
|
+
const v = {
|
|
1579
1589
|
layer: c,
|
|
1580
1590
|
useFeaturesInView: w,
|
|
1581
1591
|
view: w ? a : void 0,
|
|
@@ -1584,7 +1594,7 @@ const vo = async (e) => {
|
|
|
1584
1594
|
...m && { filter: m },
|
|
1585
1595
|
outStatisticTypes: { include: [o] }
|
|
1586
1596
|
};
|
|
1587
|
-
y = await st(
|
|
1597
|
+
y = await st(v);
|
|
1588
1598
|
const O = ["string", "small-integer", "integer"], A = d.domain?.type === "coded-value" ? d.domain : null;
|
|
1589
1599
|
(O.includes(d.type) || A) && (g = (await ct({
|
|
1590
1600
|
layer: c,
|
|
@@ -1593,12 +1603,12 @@ const vo = async (e) => {
|
|
|
1593
1603
|
field: r,
|
|
1594
1604
|
sqlWhere: V(c.definitionExpression, t.where),
|
|
1595
1605
|
...m && { filter: m }
|
|
1596
|
-
})).uniqueValueInfos.sort((q,
|
|
1606
|
+
})).uniqueValueInfos.sort((q, ke) => ke.count - q.count).slice(0, T)), g && d.domain?.type === "coded-value" && (g = g.map((q) => ({
|
|
1597
1607
|
...q,
|
|
1598
1608
|
value: A ? A.getName(q.value) ?? q.value : q.value
|
|
1599
1609
|
})));
|
|
1600
|
-
} catch (
|
|
1601
|
-
console.error("Statistics error:",
|
|
1610
|
+
} catch (v) {
|
|
1611
|
+
console.error("Statistics error:", v);
|
|
1602
1612
|
}
|
|
1603
1613
|
return {
|
|
1604
1614
|
tool: "getStatistics",
|
|
@@ -1622,7 +1632,7 @@ async function xo({
|
|
|
1622
1632
|
statisticType: r,
|
|
1623
1633
|
geometryFilter: o
|
|
1624
1634
|
}, a) {
|
|
1625
|
-
const n = we(a, "layersAndFieldsRegistry"), { mapView: s } = N(a), c = await
|
|
1635
|
+
const n = we(a, "layersAndFieldsRegistry"), { mapView: s } = N(a), c = await So({
|
|
1626
1636
|
targetLayer: e,
|
|
1627
1637
|
fieldName: t,
|
|
1628
1638
|
statisticType: r,
|
|
@@ -1725,7 +1735,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1725
1735
|
console.warn("Client-side query failed, falling back to server:", T), h = await n.queryFeatures(y);
|
|
1726
1736
|
}
|
|
1727
1737
|
}
|
|
1728
|
-
const m = h.features.map((y) => y.attributes[d]), { attributes: w } =
|
|
1738
|
+
const m = h.features.map((y) => y.attributes[d]), { attributes: w } = Se(n, h, r.timeZone);
|
|
1729
1739
|
return {
|
|
1730
1740
|
tool: "getTopFeatures",
|
|
1731
1741
|
layerName: c,
|
|
@@ -1748,7 +1758,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1748
1758
|
details: { error: h instanceof Error ? h.message : String(h) }
|
|
1749
1759
|
};
|
|
1750
1760
|
}
|
|
1751
|
-
},
|
|
1761
|
+
}, Fo = async ({
|
|
1752
1762
|
targetLayer: e,
|
|
1753
1763
|
topFilter: t,
|
|
1754
1764
|
geometryFilter: r,
|
|
@@ -1756,7 +1766,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1756
1766
|
}, a) => {
|
|
1757
1767
|
const { mapView: n } = N(a), s = await Io(e, t, n, r, o);
|
|
1758
1768
|
return JSON.stringify(s, null, 2);
|
|
1759
|
-
},
|
|
1769
|
+
}, ko = i.object({
|
|
1760
1770
|
layerId: i.string().describe("The layerId of the layer containing the geometry by which to filter."),
|
|
1761
1771
|
where: i.string().describe("The SQL-92 where clause representing the features from which to filter."),
|
|
1762
1772
|
distance: i.number().optional().describe("The buffer distance around the geometry."),
|
|
@@ -1782,7 +1792,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1782
1792
|
).default("*")
|
|
1783
1793
|
)
|
|
1784
1794
|
}),
|
|
1785
|
-
geometryFilter: i.union([
|
|
1795
|
+
geometryFilter: i.union([ko, No]).optional().describe(
|
|
1786
1796
|
"Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."
|
|
1787
1797
|
),
|
|
1788
1798
|
topFilter: i.object({
|
|
@@ -1791,11 +1801,11 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1791
1801
|
i.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")
|
|
1792
1802
|
),
|
|
1793
1803
|
groupByFields: i.array(i.string().describe("Field(s) to group results by. Returns top N per group."))
|
|
1794
|
-
}),
|
|
1804
|
+
}).required(),
|
|
1795
1805
|
useCurrentExtent: i.boolean().optional().describe(
|
|
1796
1806
|
"Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer)."
|
|
1797
1807
|
)
|
|
1798
|
-
}), qo = f(
|
|
1808
|
+
}), qo = f(Fo, {
|
|
1799
1809
|
name: "getTopFeatures",
|
|
1800
1810
|
description: 'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',
|
|
1801
1811
|
schema: zo
|
|
@@ -1840,7 +1850,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1840
1850
|
} catch (y) {
|
|
1841
1851
|
console.warn("Client-side query failed, falling back to server:", y), p = await a.queryFeatureCount(d), p > 0 && p <= Z && (h = await a.queryFeatures(d));
|
|
1842
1852
|
}
|
|
1843
|
-
const { objectIds: m, attributes: w } = h ?
|
|
1853
|
+
const { objectIds: m, attributes: w } = h ? Se(a, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
|
|
1844
1854
|
return {
|
|
1845
1855
|
tool: "queryFeatures",
|
|
1846
1856
|
layerName: s,
|
|
@@ -1913,7 +1923,7 @@ USE THIS TOOL FOR:
|
|
|
1913
1923
|
|
|
1914
1924
|
This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
1915
1925
|
schema: jo
|
|
1916
|
-
}), Oo = [
|
|
1926
|
+
}), Oo = [vo, Co, qo, Go], Vn = [io, Yr, Hr], Mo = new rt(Oo);
|
|
1917
1927
|
async function Un(e, t) {
|
|
1918
1928
|
const { messages: r } = await Mo.invoke({ messages: e.dataExplorationMessages }, t), o = [], a = [];
|
|
1919
1929
|
for (const n of r) {
|
|
@@ -1942,7 +1952,7 @@ async function Un(e, t) {
|
|
|
1942
1952
|
}
|
|
1943
1953
|
o.push(c), c.details && typeof c.details == "object" && "error" in c.details ? a.push(`- ${c.tool}: Error - ${String(c.details.error)}`) : a.push(`- ${c.layerName}: ${c.summary}`);
|
|
1944
1954
|
}
|
|
1945
|
-
return await
|
|
1955
|
+
return await S({ text: `Finished executing layer query tool: ${a.join(", ")}` }, t), {
|
|
1946
1956
|
...e,
|
|
1947
1957
|
dataExplorationMessages: [...e.dataExplorationMessages, ...r],
|
|
1948
1958
|
queryResponse: o,
|
|
@@ -2225,13 +2235,13 @@ async function ie(e, t, r, o, a) {
|
|
|
2225
2235
|
message: Ho(e, a),
|
|
2226
2236
|
context: new Wo(t)
|
|
2227
2237
|
};
|
|
2228
|
-
Q.conversationId && (n.conversationId = Q.conversationId), await
|
|
2238
|
+
Q.conversationId && (n.conversationId = Q.conversationId), await S({ text: "Attempting to generate a cypher query from your prompt..." }, o);
|
|
2229
2239
|
const s = await le(`${r}/chat`, {
|
|
2230
2240
|
method: "post",
|
|
2231
2241
|
body: JSON.stringify(n),
|
|
2232
2242
|
headers: {
|
|
2233
2243
|
"Content-Type": "application/json",
|
|
2234
|
-
token: ce.findCredential(
|
|
2244
|
+
token: ce.findCredential(k.getDefault().url)?.token ?? ""
|
|
2235
2245
|
}
|
|
2236
2246
|
});
|
|
2237
2247
|
if (s.httpStatus !== 200)
|
|
@@ -2243,7 +2253,7 @@ async function ie(e, t, r, o, a) {
|
|
|
2243
2253
|
const u = Date.now();
|
|
2244
2254
|
let l = s.data.sequenceNumber, d = "", p = "", h = 1;
|
|
2245
2255
|
for (; !c; ) {
|
|
2246
|
-
await new Promise((w) => setTimeout(w, 1e3)), await
|
|
2256
|
+
await new Promise((w) => setTimeout(w, 1e3)), await S(
|
|
2247
2257
|
{ text: `Periodically requesting status of job from ArcGIS AI Services${"...".substring(0, h)}` },
|
|
2248
2258
|
o
|
|
2249
2259
|
), h = h % 3 + 1;
|
|
@@ -2256,7 +2266,7 @@ async function ie(e, t, r, o, a) {
|
|
|
2256
2266
|
}),
|
|
2257
2267
|
headers: {
|
|
2258
2268
|
"Content-Type": "application/json",
|
|
2259
|
-
token: ce.findCredential(
|
|
2269
|
+
token: ce.findCredential(k.getDefault().url)?.token ?? ""
|
|
2260
2270
|
}
|
|
2261
2271
|
});
|
|
2262
2272
|
if (m.httpStatus !== 200)
|
|
@@ -2273,7 +2283,7 @@ async function ie(e, t, r, o, a) {
|
|
|
2273
2283
|
}
|
|
2274
2284
|
return { graphQuery: d, explanation: p };
|
|
2275
2285
|
}
|
|
2276
|
-
const
|
|
2286
|
+
const F = 3;
|
|
2277
2287
|
function Re(e, t = 100) {
|
|
2278
2288
|
const r = {};
|
|
2279
2289
|
for (const o of Object.entries(e.properties ?? {})) {
|
|
@@ -2311,10 +2321,10 @@ const Zo = async ({
|
|
|
2311
2321
|
break;
|
|
2312
2322
|
if (!g && s && Date.now() - y > s)
|
|
2313
2323
|
return l.abort(), { type: "timeout" };
|
|
2314
|
-
for (const
|
|
2324
|
+
for (const v of E) {
|
|
2315
2325
|
if (w++, n && w > n)
|
|
2316
2326
|
return l.abort(), { type: "success", rowLimitReached: !0, resultHeader: c, processedResult: u };
|
|
2317
|
-
u = o(u,
|
|
2327
|
+
u = o(u, v);
|
|
2318
2328
|
}
|
|
2319
2329
|
}
|
|
2320
2330
|
} catch (h) {
|
|
@@ -2336,7 +2346,7 @@ async function $e({
|
|
|
2336
2346
|
config: u
|
|
2337
2347
|
}) {
|
|
2338
2348
|
let l;
|
|
2339
|
-
for (let d = 1; d <=
|
|
2349
|
+
for (let d = 1; d <= F; d++) {
|
|
2340
2350
|
let p;
|
|
2341
2351
|
try {
|
|
2342
2352
|
p = await ie(e, t.dataModel, r, u, l);
|
|
@@ -2347,7 +2357,7 @@ async function $e({
|
|
|
2347
2357
|
error: w
|
|
2348
2358
|
};
|
|
2349
2359
|
}
|
|
2350
|
-
await
|
|
2360
|
+
await S(
|
|
2351
2361
|
{
|
|
2352
2362
|
text: `Attempting to execute query: ${p.graphQuery.substring(0, 500)}${p.graphQuery.length > 500 ? "..." : ""}`
|
|
2353
2363
|
},
|
|
@@ -2380,7 +2390,7 @@ async function $e({
|
|
|
2380
2390
|
graphQuery: p.graphQuery,
|
|
2381
2391
|
explanation: p.explanation
|
|
2382
2392
|
};
|
|
2383
|
-
if (d >=
|
|
2393
|
+
if (d >= F)
|
|
2384
2394
|
return h.type === "timeout" ? {
|
|
2385
2395
|
type: "timeout",
|
|
2386
2396
|
errorMessage: m,
|
|
@@ -2397,13 +2407,13 @@ async function $e({
|
|
|
2397
2407
|
failedGraphQuery: p.graphQuery,
|
|
2398
2408
|
executionError: m,
|
|
2399
2409
|
attemptCount: d
|
|
2400
|
-
}, await
|
|
2410
|
+
}, await S(
|
|
2401
2411
|
{ text: `Attempt ${d} failed with error: ${m}. Retrying...` },
|
|
2402
2412
|
u
|
|
2403
2413
|
);
|
|
2404
2414
|
}
|
|
2405
2415
|
throw new Error(
|
|
2406
|
-
`Failed to execute generated cypher due to an unexpected error after ${
|
|
2416
|
+
`Failed to execute generated cypher due to an unexpected error after ${F} attempts.`
|
|
2407
2417
|
);
|
|
2408
2418
|
}
|
|
2409
2419
|
const Yo = async ({
|
|
@@ -2530,7 +2540,7 @@ async function na(e, t, r, o, a) {
|
|
|
2530
2540
|
throw new Error(`Failed to add records to the link chart. ${p}`);
|
|
2531
2541
|
}
|
|
2532
2542
|
const { graphQuery: c, explanation: u, processedResult: l } = s, d = Array.from(l.values());
|
|
2533
|
-
return await
|
|
2543
|
+
return await S(
|
|
2534
2544
|
{
|
|
2535
2545
|
text: `Query Results parsed into ${d.length} unique relationships and entities. Atempting to add to link chart...`
|
|
2536
2546
|
},
|
|
@@ -2548,7 +2558,7 @@ Explanation: ${u}`);
|
|
|
2548
2558
|
const Ee = "addRecords", ia = i.object({
|
|
2549
2559
|
prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
|
|
2550
2560
|
}), sa = async ({ prompt: e }, t) => {
|
|
2551
|
-
const { knowledgeGraph: r } = await G(t), o = H(t), { view: a } = o, s =
|
|
2561
|
+
const { knowledgeGraph: r } = await G(t), o = H(t), { view: a } = o, s = k.getDefault().helperServices;
|
|
2552
2562
|
let c = e;
|
|
2553
2563
|
if (z(a)) {
|
|
2554
2564
|
const l = a.map, { allNamedTypesFullyDynamic: d, idTypePairs: p, dynamicTypes: h } = aa(l), m = await Y("arcgis_knowledge_current_map_context");
|
|
@@ -2649,7 +2659,7 @@ const te = "changeNonspatialVisibility", pa = i.object({
|
|
|
2649
2659
|
});
|
|
2650
2660
|
async function ma(e, t, r, o, a) {
|
|
2651
2661
|
let n;
|
|
2652
|
-
for (let s = 1; s <=
|
|
2662
|
+
for (let s = 1; s <= F; s++) {
|
|
2653
2663
|
const { graphQuery: c, explanation: u } = await ie(
|
|
2654
2664
|
e,
|
|
2655
2665
|
t.dataModel,
|
|
@@ -2658,14 +2668,14 @@ async function ma(e, t, r, o, a) {
|
|
|
2658
2668
|
n
|
|
2659
2669
|
);
|
|
2660
2670
|
try {
|
|
2661
|
-
await
|
|
2671
|
+
await S({ text: `Attempting to create link chart from derived query: ${c}` }, a);
|
|
2662
2672
|
const l = await dt.fromCypherQuery(
|
|
2663
2673
|
t,
|
|
2664
2674
|
new ge({
|
|
2665
2675
|
openCypherQuery: c
|
|
2666
2676
|
})
|
|
2667
2677
|
);
|
|
2668
|
-
await
|
|
2678
|
+
await S({ text: "Link chart created successfully, loading..." }, a), await l.load();
|
|
2669
2679
|
const d = o.map;
|
|
2670
2680
|
return o.map = l, await o.when(), await qe.whenOnce(() => !o.updating), l.entityCount === 0 && l.relationshipCount === 0 ? (o.map === l && (o.map = d), l.destroy(), {
|
|
2671
2681
|
type: "error",
|
|
@@ -2682,21 +2692,21 @@ Explanation: ${u}`
|
|
|
2682
2692
|
});
|
|
2683
2693
|
} catch (l) {
|
|
2684
2694
|
const d = l instanceof Error ? l.message : String(l);
|
|
2685
|
-
if (s >=
|
|
2695
|
+
if (s >= F)
|
|
2686
2696
|
throw new Error(
|
|
2687
|
-
`Failed to create link chart after ${
|
|
2697
|
+
`Failed to create link chart after ${F} attempts. Last error: ${d}`
|
|
2688
2698
|
);
|
|
2689
2699
|
n = {
|
|
2690
2700
|
failedGraphQuery: c,
|
|
2691
2701
|
executionError: d,
|
|
2692
2702
|
attemptCount: s
|
|
2693
|
-
}, await
|
|
2703
|
+
}, await S(
|
|
2694
2704
|
{ text: `Attempt ${s} to create link chart failed with error: ${d}. Retrying ...` },
|
|
2695
2705
|
a
|
|
2696
2706
|
);
|
|
2697
2707
|
}
|
|
2698
2708
|
}
|
|
2699
|
-
throw new Error(`Failed to create link chart after ${
|
|
2709
|
+
throw new Error(`Failed to create link chart after ${F} attempts.`);
|
|
2700
2710
|
}
|
|
2701
2711
|
const _ = "createLinkChart", ya = i.object({
|
|
2702
2712
|
prompt: i.string().describe(
|
|
@@ -2712,7 +2722,7 @@ const _ = "createLinkChart", ya = i.object({
|
|
|
2712
2722
|
error: new Error()
|
|
2713
2723
|
};
|
|
2714
2724
|
{
|
|
2715
|
-
const n =
|
|
2725
|
+
const n = k.getDefault().helperServices, s = await ma(
|
|
2716
2726
|
e,
|
|
2717
2727
|
r,
|
|
2718
2728
|
`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -2743,7 +2753,7 @@ REQUEST LIMIT: If the user does not specifically request for no limits or an exp
|
|
|
2743
2753
|
DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for specific column names in the result, ensure that the generated query has descriptive column names (using AS statements) to make the results easier to understand when displayed in a table format.`
|
|
2744
2754
|
)
|
|
2745
2755
|
}), wa = async ({ prompt: e }, t) => {
|
|
2746
|
-
const { knowledgeGraph: r } = await G(t), a =
|
|
2756
|
+
const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await $e({
|
|
2747
2757
|
prompt: e,
|
|
2748
2758
|
kg: r,
|
|
2749
2759
|
graphQueryServiceUrl: `${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -2801,7 +2811,7 @@ ${p.length > d ? `Showing top ${d} results:
|
|
|
2801
2811
|
}), Ie = "generateCypher", ba = i.object({
|
|
2802
2812
|
prompt: i.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
|
|
2803
2813
|
}), Ta = async ({ prompt: e }, t) => {
|
|
2804
|
-
const { knowledgeGraph: r } = await G(t), a =
|
|
2814
|
+
const { knowledgeGraph: r } = await G(t), a = k.getDefault().helperServices, n = await Jo(
|
|
2805
2815
|
e,
|
|
2806
2816
|
r.dataModel,
|
|
2807
2817
|
`${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -2816,7 +2826,7 @@ ${p.length > d ? `Showing top ${d} results:
|
|
|
2816
2826
|
name: Ie,
|
|
2817
2827
|
description: "Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",
|
|
2818
2828
|
schema: ba
|
|
2819
|
-
}),
|
|
2829
|
+
}), va = (e) => {
|
|
2820
2830
|
const t = e.dataModel, r = /* @__PURE__ */ new Map();
|
|
2821
2831
|
for (const c of t.searchIndexes)
|
|
2822
2832
|
if (c.supportedCategory !== "esriTypeMetaEntityProvenance")
|
|
@@ -2833,10 +2843,10 @@ ${a.map(({ name: c }) => `${c}: [${Array.from(r.get(c) ?? []).join(", ")}]`).joi
|
|
|
2833
2843
|
|
|
2834
2844
|
${s}`;
|
|
2835
2845
|
};
|
|
2836
|
-
async function
|
|
2846
|
+
async function Sa(e, t) {
|
|
2837
2847
|
const r = await Y("arcgis_knowledge_lucene_generation_prompt"), o = {
|
|
2838
2848
|
inquiry: e,
|
|
2839
|
-
dataModelForSearch:
|
|
2849
|
+
dataModelForSearch: va(t)
|
|
2840
2850
|
}, a = i.enum(["entity", "relationship", "both"]).describe("The graph element category to search against - entity, relationship, or both"), n = i.number().int().positive().nullable().describe(
|
|
2841
2851
|
"The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."
|
|
2842
2852
|
), s = i.array(
|
|
@@ -2857,15 +2867,15 @@ async function va(e, t) {
|
|
|
2857
2867
|
schema: c
|
|
2858
2868
|
});
|
|
2859
2869
|
}
|
|
2860
|
-
const
|
|
2870
|
+
const Fe = "searchGraphData", xa = i.object({
|
|
2861
2871
|
prompt: i.string().describe(
|
|
2862
2872
|
"The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results."
|
|
2863
2873
|
)
|
|
2864
2874
|
}), Ra = async ({ prompt: e }, t) => {
|
|
2865
2875
|
const { knowledgeGraph: r } = await G(t);
|
|
2866
|
-
await
|
|
2867
|
-
const o = await
|
|
2868
|
-
await
|
|
2876
|
+
await S({ text: "Generating search query for the user inquiry" }, t);
|
|
2877
|
+
const o = await Sa(e, r);
|
|
2878
|
+
await S({ text: "Executing graph search with generated search query" }, t);
|
|
2869
2879
|
const a = await Yo({
|
|
2870
2880
|
kg: r,
|
|
2871
2881
|
searchQuery: o.query,
|
|
@@ -2888,7 +2898,7 @@ const ke = "searchGraphData", xa = i.object({
|
|
|
2888
2898
|
);
|
|
2889
2899
|
const n = 10, s = a.results.slice(0, n);
|
|
2890
2900
|
return {
|
|
2891
|
-
toolName:
|
|
2901
|
+
toolName: Fe,
|
|
2892
2902
|
status: "success",
|
|
2893
2903
|
summary: `To answer the query, the following lucene query was generated and executed:
|
|
2894
2904
|
Query: ${o.query}
|
|
@@ -2910,7 +2920,7 @@ const ke = "searchGraphData", xa = i.object({
|
|
|
2910
2920
|
}
|
|
2911
2921
|
};
|
|
2912
2922
|
}, oi = f(Ra, {
|
|
2913
|
-
name:
|
|
2923
|
+
name: Fe,
|
|
2914
2924
|
description: "Allows users to search the knowledge graph for text matching their inquiry, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.",
|
|
2915
2925
|
schema: xa
|
|
2916
2926
|
});
|
|
@@ -2945,20 +2955,20 @@ export {
|
|
|
2945
2955
|
Jn as h,
|
|
2946
2956
|
G as i,
|
|
2947
2957
|
Hn as j,
|
|
2948
|
-
|
|
2958
|
+
vn as k,
|
|
2949
2959
|
Bn as l,
|
|
2950
|
-
|
|
2960
|
+
Sn as m,
|
|
2951
2961
|
xn as n,
|
|
2952
2962
|
Rn as o,
|
|
2953
2963
|
$n as p,
|
|
2954
2964
|
ti as q,
|
|
2955
|
-
|
|
2965
|
+
kn as r,
|
|
2956
2966
|
oi as s,
|
|
2957
2967
|
_t as t,
|
|
2958
2968
|
En as u,
|
|
2959
2969
|
Cn as v,
|
|
2960
2970
|
In as w,
|
|
2961
|
-
|
|
2971
|
+
Fn as x,
|
|
2962
2972
|
$ as y,
|
|
2963
2973
|
Nn as z
|
|
2964
2974
|
};
|