@arcgis/ai-agents 5.1.0-next.109 → 5.1.0-next.111
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/agents/arcgisKnowledge/context/arcgisKnowledgeContext.d.ts +1 -2
- package/dist/agents/arcgisKnowledge/context/getArcgisKnowledgeContext.d.ts +2 -0
- package/dist/agents/arcgisKnowledge/nodes/arcgisKnowledgeLLM.d.ts +1 -1
- package/dist/agents/arcgisKnowledge/utils/mapUtils.d.ts +1 -1
- package/dist/arcgis_knowledge_tool_prompt-C5ubmorM.js +33 -0
- package/dist/index.js +117 -98
- package/package.json +2 -2
- package/dist/arcgis_knowledge_tool_prompt-BxNenktf.js +0 -26
|
@@ -12,5 +12,4 @@ export type ArcgisKnowledgeContext = {
|
|
|
12
12
|
view: LinkChartView | MapView;
|
|
13
13
|
knowledgeGraph?: never;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export declare const serviceContextKeys: readonly ["knowledgeGraph", "view"];
|
|
15
|
+
export type KnowledgeGraphSourceType = "knowledgeGraph" | "linkChart" | "map";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
2
|
+
import { KnowledgeGraphSourceType } from './arcgisKnowledgeContext';
|
|
2
3
|
import { default as KnowledgeGraph } from '@arcgis/core/rest/knowledgeGraph/KnowledgeGraph.js';
|
|
3
4
|
import { default as LinkChartView } from '@arcgis/core/views/LinkChartView.js';
|
|
4
5
|
import { default as MapView } from '@arcgis/core/views/MapView.js';
|
|
5
6
|
export declare function getViewContext(config?: RunnableConfig): {
|
|
6
7
|
view: LinkChartView | MapView;
|
|
7
8
|
};
|
|
9
|
+
export declare function getContextType(config?: RunnableConfig): KnowledgeGraphSourceType;
|
|
8
10
|
export declare function getKnowledgeGraphContext(config?: RunnableConfig): Promise<{
|
|
9
11
|
knowledgeGraph: KnowledgeGraph;
|
|
10
12
|
}>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
2
2
|
import { ArcgisKnowledgeGraphStateType } from '../state/arcgisKnowledgeState';
|
|
3
|
-
export declare function arcgisKnowledgeLLM(state: ArcgisKnowledgeGraphStateType,
|
|
3
|
+
export declare function arcgisKnowledgeLLM(state: ArcgisKnowledgeGraphStateType, config?: RunnableConfig): Promise<ArcgisKnowledgeGraphStateType>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as LinkChartView } from '@arcgis/core/views/LinkChartView.js';
|
|
2
2
|
import { default as MapView } from '@arcgis/core/views/MapView.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function validateMapLayers(mapView: MapView): void;
|
|
4
4
|
export declare function isMapView(view: LinkChartView | MapView | undefined): view is MapView;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const e = `# ArcgisKnowledge Tool Instructions
|
|
2
|
+
|
|
3
|
+
You are an assistant that helps users answer questions and perform operations on their knowledge graph, map or link chart. You have been assigned the task below, which must be achieved by calling a single tool.
|
|
4
|
+
|
|
5
|
+
## Task Details:
|
|
6
|
+
|
|
7
|
+
Assigned task:
|
|
8
|
+
{assignedTask}
|
|
9
|
+
|
|
10
|
+
User Request:
|
|
11
|
+
{userRequest}
|
|
12
|
+
|
|
13
|
+
Prior steps:
|
|
14
|
+
{priorSteps}
|
|
15
|
+
|
|
16
|
+
Context type:
|
|
17
|
+
{contextType}
|
|
18
|
+
|
|
19
|
+
## Rules:
|
|
20
|
+
|
|
21
|
+
1. Use the provided context type above for the following rule. If the context type is a map, you may never call any of the following arcgisKnowledge tools: changeNonspatialVisibility, applyLayout, createLinkChart.
|
|
22
|
+
|
|
23
|
+
2. Use the provided context type above for the following rule. If the context type is a knowledgeGraph, you may never call any of the following arcgisKnowledge tools: changeNonspatialVisibility, applyLayout, createLinkChart, addRecords.
|
|
24
|
+
|
|
25
|
+
3. If no tools apply to the assigned task, return zero tool calls and an empty message.
|
|
26
|
+
|
|
27
|
+
4. If a tool is found for the assigned task, call exactly one arcgisKnowledge tool, with the appropriate arguments given the assigned task. Use the provided user request or prior steps only if needed for context based on the assigned task.
|
|
28
|
+
|
|
29
|
+
5. CRITICAL: You are FORBIDDEN from making multiple tool calls. You MUST make exactly ONE tool call or ZERO tool calls.
|
|
30
|
+
`;
|
|
31
|
+
export {
|
|
32
|
+
e as default
|
|
33
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Annotation as v, StateGraph as
|
|
1
|
+
import { Annotation as v, StateGraph as U, START as B, END as C, messagesStateReducer as ke, NodeInterrupt as lt } from "@langchain/langgraph/web";
|
|
2
2
|
import { createAgentRuntimeStateWithSharedState as ct, invokeToolPrompt as P, sendTraceMessage as m, invokeStructuredPrompt as Fe, createAgentRuntimeState as ee, invokeTextPrompt as qe, sendUXSuggestion as k } from "@arcgis/ai-orchestrator";
|
|
3
3
|
import { tool as b } from "@langchain/core/tools";
|
|
4
4
|
import oe from "@arcgis/core/config.js";
|
|
@@ -23,7 +23,7 @@ import { createRenderer as bt } from "@arcgis/core/smartMapping/renderers/pieCha
|
|
|
23
23
|
import { getSchemesByTag as St, getSchemes as vt } from "@arcgis/core/smartMapping/symbology/pieChart.js";
|
|
24
24
|
import { getBackgroundColorTheme as we } from "@arcgis/core/views/support/colorUtils.js";
|
|
25
25
|
import { createAgeRenderer as xt, createContinuousRenderer as Tt } from "@arcgis/core/smartMapping/renderers/color.js";
|
|
26
|
-
import { getSchemesByTag as
|
|
26
|
+
import { getSchemesByTag as de } from "@arcgis/core/smartMapping/symbology/color.js";
|
|
27
27
|
import { createContinuousRenderer as Et } from "@arcgis/core/smartMapping/renderers/univariateColorSize.js";
|
|
28
28
|
import { createRenderer as Rt } from "@arcgis/core/smartMapping/renderers/dotDensity.js";
|
|
29
29
|
import { getSchemesByTag as $t } from "@arcgis/core/smartMapping/symbology/dotDensity.js";
|
|
@@ -43,21 +43,21 @@ import _e from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
|
|
|
43
43
|
import Se from "@arcgis/core/request.js";
|
|
44
44
|
import ve from "@arcgis/core/identity/IdentityManager.js";
|
|
45
45
|
import Pt from "@arcgis/core/WebLinkChart.js";
|
|
46
|
-
const
|
|
46
|
+
const Q = (e, t) => t ?? e, De = v.Root({
|
|
47
47
|
...ct(),
|
|
48
48
|
// internal to the navigation agent
|
|
49
49
|
intent: v({
|
|
50
|
-
reducer:
|
|
50
|
+
reducer: Q
|
|
51
51
|
}),
|
|
52
52
|
vectorSearchLayerResults: v({
|
|
53
|
-
reducer:
|
|
53
|
+
reducer: Q,
|
|
54
54
|
default: () => []
|
|
55
55
|
}),
|
|
56
56
|
vectorSearchFieldResults: v({
|
|
57
|
-
reducer:
|
|
57
|
+
reducer: Q
|
|
58
58
|
}),
|
|
59
59
|
navigationInternalState: v({
|
|
60
|
-
reducer:
|
|
60
|
+
reducer: Q,
|
|
61
61
|
default: () => ({
|
|
62
62
|
toolCallMessage: void 0
|
|
63
63
|
})
|
|
@@ -283,7 +283,7 @@ const xr = l.object({
|
|
|
283
283
|
name: "goToZoom",
|
|
284
284
|
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.).',
|
|
285
285
|
schema: xr
|
|
286
|
-
}),
|
|
286
|
+
}), ue = [
|
|
287
287
|
Kt,
|
|
288
288
|
Ht,
|
|
289
289
|
Xt,
|
|
@@ -298,7 +298,7 @@ const xr = l.object({
|
|
|
298
298
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md": () => import("./arcgis_knowledge_current_map_context-CfNPKOjr.js").then((e) => e.default),
|
|
299
299
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md": () => import("./arcgis_knowledge_lucene_generation_prompt-D3mtOeWu.js").then((e) => e.default),
|
|
300
300
|
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md": () => import("./arcgis_knowledge_summarize_result_prompt-D2CFAGMP.js").then((e) => e.default),
|
|
301
|
-
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md": () => import("./arcgis_knowledge_tool_prompt-
|
|
301
|
+
"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md": () => import("./arcgis_knowledge_tool_prompt-C5ubmorM.js").then((e) => e.default),
|
|
302
302
|
"../agents/dataExploration/prompts/data_explore_filter_prompt.md": () => import("./data_explore_filter_prompt-g9GTTJyj.js").then((e) => e.default),
|
|
303
303
|
"../agents/dataExploration/prompts/data_explore_query_prompt.md": () => import("./data_explore_query_prompt-DqJVadVm.js").then((e) => e.default),
|
|
304
304
|
"../agents/dataExploration/prompts/summarize_query_response_prompt.md": () => import("./summarize_query_response_prompt-uHW-P2T8.js").then((e) => e.default),
|
|
@@ -337,7 +337,7 @@ ${i}` : "", p = {
|
|
|
337
337
|
promptText: r,
|
|
338
338
|
modelTier: "fast",
|
|
339
339
|
inputVariables: p,
|
|
340
|
-
tools:
|
|
340
|
+
tools: ue
|
|
341
341
|
}), g = (h.tool_calls?.length ?? 0) > 0, w = typeof h.text == "string" ? h.text.trim() : "", y = w.length > 0;
|
|
342
342
|
return {
|
|
343
343
|
...e,
|
|
@@ -365,7 +365,7 @@ const N = (e, t = 300) => {
|
|
|
365
365
|
return { text: t };
|
|
366
366
|
};
|
|
367
367
|
async function $r(e, t) {
|
|
368
|
-
const r = new G(
|
|
368
|
+
const r = new G(ue);
|
|
369
369
|
try {
|
|
370
370
|
const a = e.navigationInternalState.toolCallMessage;
|
|
371
371
|
if (!a)
|
|
@@ -411,7 +411,7 @@ async function $r(e, t) {
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
async function Cr(e, t) {
|
|
414
|
-
const r = await R("navigation_intent_prompt"), { mapView: a } = F(t), o =
|
|
414
|
+
const r = await R("navigation_intent_prompt"), { mapView: a } = F(t), o = ue.map((h) => ({
|
|
415
415
|
name: h.name,
|
|
416
416
|
description: h.description,
|
|
417
417
|
schema: h.schema
|
|
@@ -521,13 +521,13 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
521
521
|
t
|
|
522
522
|
), r;
|
|
523
523
|
}
|
|
524
|
-
},
|
|
524
|
+
}, H = (e, t) => (r, a) => {
|
|
525
525
|
const o = a?.configurable?.services;
|
|
526
526
|
for (const n of e)
|
|
527
527
|
if (!o?.[n])
|
|
528
528
|
throw new Error(`${t} requires services.${n} to be available.`);
|
|
529
529
|
return r;
|
|
530
|
-
}, Ir = (e, t) =>
|
|
530
|
+
}, Ir = (e, t) => H(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), Nr = () => new U(De).addNode("requireNavigationServices", Ir).addNode("intentLLM", Cr).addNode("vectorSearchLayers", Fr).addNode("vectorSearchFields", Lr).addNode("agent", Er).addNode("tools", $r).addEdge(B, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
|
|
531
531
|
"intentLLM",
|
|
532
532
|
(t) => t.intent === "goToLayer" || t.intent === "goToFeatures" ? "vectorSearchLayers" : "agent",
|
|
533
533
|
{
|
|
@@ -576,7 +576,7 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
|
|
|
576
576
|
reducer: ke,
|
|
577
577
|
default: () => []
|
|
578
578
|
})
|
|
579
|
-
}), Mr = async (e, t) => (await m({ text: "Exiting Data Exploration agent" }, t), e),
|
|
579
|
+
}), Mr = async (e, t) => (await m({ text: "Exiting Data Exploration agent" }, t), e), pe = async (e, t) => {
|
|
580
580
|
const r = e.tool_calls ?? [];
|
|
581
581
|
if (r.length === 0) {
|
|
582
582
|
await m({ text: `LLM did not request any tool calls: ${String(e?.content)}` }, t);
|
|
@@ -632,7 +632,7 @@ const _r = (e) => {
|
|
|
632
632
|
function Y(e) {
|
|
633
633
|
return "point" in e && e.point !== void 0;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function K(e) {
|
|
636
636
|
return "layerId" in e && e.layerId !== void 0;
|
|
637
637
|
}
|
|
638
638
|
const te = async (e, t) => {
|
|
@@ -644,7 +644,7 @@ const te = async (e, t) => {
|
|
|
644
644
|
spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
|
|
645
645
|
}) };
|
|
646
646
|
}
|
|
647
|
-
if (
|
|
647
|
+
if (K(e)) {
|
|
648
648
|
const r = t.map?.allLayers.find(
|
|
649
649
|
(o) => o.id === e.layerId
|
|
650
650
|
);
|
|
@@ -777,7 +777,7 @@ const te = async (e, t) => {
|
|
|
777
777
|
name: "setFeatureEffect",
|
|
778
778
|
description: "Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",
|
|
779
779
|
schema: Hr
|
|
780
|
-
}),
|
|
780
|
+
}), se = (e) => {
|
|
781
781
|
if (e instanceof Date)
|
|
782
782
|
return Number.isNaN(e.getTime()) ? null : e;
|
|
783
783
|
if (typeof e == "number" && Number.isFinite(e)) {
|
|
@@ -788,7 +788,7 @@ const te = async (e, t) => {
|
|
|
788
788
|
}, Jr = (e) => !e || e === "system" ? Intl.DateTimeFormat().resolvedOptions().timeZone : e === "unknown" ? "UTC" : e, Yr = (e) => {
|
|
789
789
|
if (typeof e == "string" && e)
|
|
790
790
|
return e;
|
|
791
|
-
const t =
|
|
791
|
+
const t = se(e);
|
|
792
792
|
return t ? t.toISOString().slice(0, 10) : null;
|
|
793
793
|
}, Pe = () => {
|
|
794
794
|
const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
|
|
@@ -802,13 +802,13 @@ const te = async (e, t) => {
|
|
|
802
802
|
if (a === "time-only") {
|
|
803
803
|
if (typeof e == "string" && e)
|
|
804
804
|
return gt(e, Z("long-time"));
|
|
805
|
-
const n =
|
|
805
|
+
const n = se(e);
|
|
806
806
|
return n ? fe(n, {
|
|
807
807
|
...Z("long-time"),
|
|
808
808
|
timeZone: "UTC"
|
|
809
809
|
}) : e;
|
|
810
810
|
}
|
|
811
|
-
const o =
|
|
811
|
+
const o = se(e);
|
|
812
812
|
return o ? fe(o, {
|
|
813
813
|
...Z("short-date-short-time"),
|
|
814
814
|
timeZone: Jr(r)
|
|
@@ -912,7 +912,7 @@ const ca = l.object({
|
|
|
912
912
|
name: "getAttribute",
|
|
913
913
|
description: "Returns an attribute value for a given feature.",
|
|
914
914
|
schema: ca
|
|
915
|
-
}),
|
|
915
|
+
}), he = (e, t, r) => r ? e.hasAllFeaturesInView && e.availableFields === t : e.hasAllFeatures && e.availableFields === t;
|
|
916
916
|
function X(e, t) {
|
|
917
917
|
let r = e ?? "";
|
|
918
918
|
return t != null && t && (r = r ? `(${r}) AND (${t})` : t), r || null;
|
|
@@ -930,8 +930,8 @@ const ua = async (e) => {
|
|
|
930
930
|
if ("error" in T)
|
|
931
931
|
throw new Error(T.error);
|
|
932
932
|
if (!T.geometry)
|
|
933
|
-
throw
|
|
934
|
-
if (
|
|
933
|
+
throw K(s) ? new Error(`No features found matching: ${s.where}`) : new Error("Failed to create geometry");
|
|
934
|
+
if (K(s)) {
|
|
935
935
|
const D = o.map?.allLayers.find((L) => L.id === s.layerId);
|
|
936
936
|
h = {
|
|
937
937
|
geometryLayerName: D?.title ?? D?.id,
|
|
@@ -954,7 +954,7 @@ const ua = async (e) => {
|
|
|
954
954
|
spatialRelationship: "intersects"
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
|
-
const w =
|
|
957
|
+
const w = he(c, [r], !1);
|
|
958
958
|
let y = null, f = null;
|
|
959
959
|
const x = 10;
|
|
960
960
|
if (u.type !== "geometry" && u.type !== "oid" && u.type !== "global-id")
|
|
@@ -1102,7 +1102,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1102
1102
|
} else {
|
|
1103
1103
|
const y = n.createQuery();
|
|
1104
1104
|
y.where = X(n.definitionExpression, e.where || "1=1"), y.outFields = p.length ? p : ["*"], y.orderByFields = t.orderByFields, y.num = t.topCount, c && (y.geometry = c, y.spatialRelationship = "intersects"), a?.distance && (y.distance = a.distance), a?.units && (y.units = a.units), y.outSpatialReference = r.spatialReference;
|
|
1105
|
-
const f =
|
|
1105
|
+
const f = he(s, e.outFields, o ?? !1);
|
|
1106
1106
|
try {
|
|
1107
1107
|
h = f ? await s.queryFeatures(y) : await n.queryFeatures(y);
|
|
1108
1108
|
} catch (x) {
|
|
@@ -1190,7 +1190,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1190
1190
|
const y = await te(r, t);
|
|
1191
1191
|
if ("error" in y) {
|
|
1192
1192
|
const f = { error: y.error };
|
|
1193
|
-
if (
|
|
1193
|
+
if (K(r)) {
|
|
1194
1194
|
const x = t.map?.allLayers.find((E) => E.id === r.layerId);
|
|
1195
1195
|
f.geometryLayerName = x?.title ?? x?.id, f.geometryLayerId = r.layerId, f.geometryWhere = r.where;
|
|
1196
1196
|
} else Y(r) && (f.point = r.point);
|
|
@@ -1203,7 +1203,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1203
1203
|
}
|
|
1204
1204
|
if (!y.geometry) {
|
|
1205
1205
|
const f = {};
|
|
1206
|
-
if (
|
|
1206
|
+
if (K(r)) {
|
|
1207
1207
|
const x = t.map?.allLayers.find((E) => E.id === r.layerId);
|
|
1208
1208
|
f.error = `No features found matching: ${r.where}`, f.geometryLayerName = x?.title ?? x?.id, f.geometryLayerId = r.layerId, f.geometryWhere = r.where;
|
|
1209
1209
|
} else Y(r) && (f.error = "Failed to create point geometry", f.point = r.point);
|
|
@@ -1216,7 +1216,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
|
|
|
1216
1216
|
}
|
|
1217
1217
|
i = y.geometry;
|
|
1218
1218
|
} else a && (i = t.extent.clone());
|
|
1219
|
-
const c =
|
|
1219
|
+
const c = he(n, e.outFields, a ?? !1), d = o.objectIdField, u = o.createQuery();
|
|
1220
1220
|
u.where = X(o.definitionExpression, e.where || "1=1"), u.outFields = e.outFields.includes("*") ? ["*"] : [.../* @__PURE__ */ new Set([...e.outFields, d])], u.orderByFields = e.orderByFields, i && (u.geometry = i, u.spatialRelationship = "intersects"), r?.distance && (u.distance = r.distance), r?.units && (u.units = r.units), u.outSpatialReference = t.spatialReference;
|
|
1221
1221
|
let p, h;
|
|
1222
1222
|
try {
|
|
@@ -1324,7 +1324,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
|
1324
1324
|
// Don't overwrite outputMessage if query already set it
|
|
1325
1325
|
};
|
|
1326
1326
|
const u = [...c, i], p = i.content.toString();
|
|
1327
|
-
return await
|
|
1327
|
+
return await pe(i, t), { ...e, dataExplorationMessages: u, outputMessage: p };
|
|
1328
1328
|
}, qa = async (e, t) => {
|
|
1329
1329
|
await m({ text: "Requesting LLM for layer query results" }, t);
|
|
1330
1330
|
const a = await R("data_explore_query_prompt");
|
|
@@ -1344,7 +1344,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
|
|
|
1344
1344
|
inputVariables: s,
|
|
1345
1345
|
tools: Ke
|
|
1346
1346
|
}), c = i.content.toString();
|
|
1347
|
-
return await
|
|
1347
|
+
return await pe(i, t), {
|
|
1348
1348
|
...e,
|
|
1349
1349
|
dataExplorationMessages: [...e.dataExplorationMessages, i],
|
|
1350
1350
|
outputMessage: c,
|
|
@@ -1580,10 +1580,10 @@ ${i}` : c = "Vector search completed. No matching layers found.", await m({ text
|
|
|
1580
1580
|
t
|
|
1581
1581
|
), new Error(`Vector search failed: ${r instanceof Error ? r.message : String(r)}`);
|
|
1582
1582
|
}
|
|
1583
|
-
}, Wa = (e, t) =>
|
|
1583
|
+
}, Wa = (e, t) => H(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
|
|
1584
1584
|
e,
|
|
1585
1585
|
t
|
|
1586
|
-
), Ua = () => new
|
|
1586
|
+
), Ua = () => new U(je).addNode("requireDataExplorationServices", Wa).addNode("vectorSearchLayers", Ka).addNode("vectorSearchFields", Va).addNode("fieldStatistics", Ga).addNode("queryAgent", qa).addNode("queryTools", Aa).addNode("summarizeQueryResponseLLM", La).addNode("filterAgent", Fa).addNode("filterTools", Ia).addNode("earlyExit", Mr).addEdge(B, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
|
|
1587
1587
|
"vectorSearchLayers",
|
|
1588
1588
|
(t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
1589
1589
|
).addConditionalEdges(
|
|
@@ -1760,7 +1760,7 @@ const oo = l.object({
|
|
|
1760
1760
|
function so(e) {
|
|
1761
1761
|
const { fields: t, layer: r, view: a, theme: o, colorSchemeTags: n } = e, s = t[0];
|
|
1762
1762
|
let i;
|
|
1763
|
-
return n && (i =
|
|
1763
|
+
return n && (i = de({
|
|
1764
1764
|
geometryType: r.geometryType,
|
|
1765
1765
|
includedTags: n,
|
|
1766
1766
|
theme: o || "high-to-low"
|
|
@@ -1839,7 +1839,7 @@ function ho(e) {
|
|
|
1839
1839
|
let { theme: n } = e, s = t[1];
|
|
1840
1840
|
const i = t[0];
|
|
1841
1841
|
let c;
|
|
1842
|
-
return o && (c =
|
|
1842
|
+
return o && (c = de({
|
|
1843
1843
|
geometryType: r.geometryType,
|
|
1844
1844
|
includedTags: o,
|
|
1845
1845
|
theme: n || "high-to-low"
|
|
@@ -1917,7 +1917,7 @@ function bo(e) {
|
|
|
1917
1917
|
const { fields: t, layer: r, view: a, colorSchemeTags: o, theme: n } = e;
|
|
1918
1918
|
let s, i;
|
|
1919
1919
|
const c = t[0];
|
|
1920
|
-
return o && (i =
|
|
1920
|
+
return o && (i = de({
|
|
1921
1921
|
geometryType: r.geometryType,
|
|
1922
1922
|
includedTags: o,
|
|
1923
1923
|
theme: n || "high-to-low"
|
|
@@ -2553,7 +2553,7 @@ Fields: This style requires a single field which may be a string, number, or dat
|
|
|
2553
2553
|
inputVariables: a,
|
|
2554
2554
|
tools: Ue
|
|
2555
2555
|
});
|
|
2556
|
-
return await
|
|
2556
|
+
return await pe(o, t), {
|
|
2557
2557
|
...e,
|
|
2558
2558
|
agentExecutionContext: {
|
|
2559
2559
|
...e.agentExecutionContext,
|
|
@@ -2631,7 +2631,7 @@ const He = v.Root({
|
|
|
2631
2631
|
...e,
|
|
2632
2632
|
selectedLayerId: o ?? e.vectorSearchLayerIds[0]
|
|
2633
2633
|
};
|
|
2634
|
-
}, bn = (e, t) =>
|
|
2634
|
+
}, bn = (e, t) => H(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(e, t), Sn = () => new U(He).addNode("requireLayerStylingServices", bn).addNode("vectorSearchLayers", Ya).addNode("layerSelectionHITL", wn).addNode("vectorSearchFields", Za).addNode("populateLayerFieldInfo", fn).addNode("agent", mn).addNode("tools", yn).addNode("earlyExit", gn).addEdge(B, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
|
|
2635
2635
|
"layerSelectionHITL",
|
|
2636
2636
|
(t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
2637
2637
|
).addConditionalEdges(
|
|
@@ -2651,7 +2651,7 @@ const He = v.Root({
|
|
|
2651
2651
|
...ee(),
|
|
2652
2652
|
// internal to the help agent
|
|
2653
2653
|
helpInternalState: v({
|
|
2654
|
-
reducer:
|
|
2654
|
+
reducer: Q,
|
|
2655
2655
|
default: () => ({
|
|
2656
2656
|
toolCallMessage: void 0
|
|
2657
2657
|
})
|
|
@@ -2731,7 +2731,7 @@ async function Cn(e, t) {
|
|
|
2731
2731
|
};
|
|
2732
2732
|
}
|
|
2733
2733
|
}
|
|
2734
|
-
const kn = (e, t) =>
|
|
2734
|
+
const kn = (e, t) => H(["agentRegistry"], "Help Agent")(e, t);
|
|
2735
2735
|
async function Fn(e, t) {
|
|
2736
2736
|
const r = new G(Je);
|
|
2737
2737
|
try {
|
|
@@ -2764,7 +2764,7 @@ async function Fn(e, t) {
|
|
|
2764
2764
|
};
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
|
-
const qn = () => new
|
|
2767
|
+
const qn = () => new U(Ze).addNode("requireHelpServices", kn).addNode("agent", Cn).addNode("tools", Fn).addEdge(B, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => t.helpInternalState.toolCallMessage ? "tools" : C).addEdge("tools", C), Ln = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
|
|
2768
2768
|
|
|
2769
2769
|
_Example: “Tell me about this map”_
|
|
2770
2770
|
_Example: “List all layers in this map”_
|
|
@@ -2798,35 +2798,36 @@ const qn = () => new W(Ze).addNode("requireHelpServices", kn).addNode("agent", C
|
|
|
2798
2798
|
})
|
|
2799
2799
|
}), J = {
|
|
2800
2800
|
conversationId: ""
|
|
2801
|
-
}
|
|
2802
|
-
function
|
|
2801
|
+
};
|
|
2802
|
+
function me(e) {
|
|
2803
2803
|
const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
|
|
2804
2804
|
if (!t || t?.length !== 1)
|
|
2805
2805
|
throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
|
|
2806
2806
|
}
|
|
2807
|
-
function
|
|
2807
|
+
function O(e) {
|
|
2808
2808
|
return !!e?.map && !("activeLinkChartLayer" in e.map);
|
|
2809
2809
|
}
|
|
2810
2810
|
function re(e) {
|
|
2811
2811
|
const r = e?.configurable?.context;
|
|
2812
2812
|
if (!r || typeof r != "object")
|
|
2813
2813
|
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
view: o
|
|
2814
|
+
if (!("view" in r))
|
|
2815
|
+
throw new Error("View context missing");
|
|
2816
|
+
const a = r.view;
|
|
2817
|
+
return a.map && !("activeLinkChartLayer" in a.map) && me(a), {
|
|
2818
|
+
view: a
|
|
2820
2819
|
};
|
|
2821
2820
|
}
|
|
2822
|
-
|
|
2821
|
+
function In(e) {
|
|
2823
2822
|
const r = e?.configurable?.context;
|
|
2824
|
-
if (
|
|
2825
|
-
|
|
2826
|
-
const
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2823
|
+
if (Xe(e) === "knowledgeGraph")
|
|
2824
|
+
return "knowledgeGraph";
|
|
2825
|
+
const o = r.view;
|
|
2826
|
+
return O(o) ? (me(o), "map") : "linkChart";
|
|
2827
|
+
}
|
|
2828
|
+
async function V(e) {
|
|
2829
|
+
const r = e?.configurable?.context;
|
|
2830
|
+
if (Xe(e) === "knowledgeGraph")
|
|
2830
2831
|
return r;
|
|
2831
2832
|
{
|
|
2832
2833
|
const o = r.view.map;
|
|
@@ -2838,7 +2839,7 @@ async function O(e) {
|
|
|
2838
2839
|
knowledgeGraph: await be(n)
|
|
2839
2840
|
};
|
|
2840
2841
|
} else {
|
|
2841
|
-
|
|
2842
|
+
me(r.view);
|
|
2842
2843
|
const s = (r.view.map?.allLayers.find(
|
|
2843
2844
|
(c) => c.type === "knowledge-graph"
|
|
2844
2845
|
)).url;
|
|
@@ -2850,6 +2851,18 @@ async function O(e) {
|
|
|
2850
2851
|
}
|
|
2851
2852
|
}
|
|
2852
2853
|
}
|
|
2854
|
+
function Xe(e) {
|
|
2855
|
+
const r = e?.configurable?.context;
|
|
2856
|
+
if (!r || typeof r != "object")
|
|
2857
|
+
throw new Error("ArcgisKnowledgeAgent context missing");
|
|
2858
|
+
if ("knowledgeGraph" in r && "view" in r)
|
|
2859
|
+
throw new Error("Knowledge Graph context should only have a view or knowledgeGraph, but never both.");
|
|
2860
|
+
if ("knowledgeGraph" in r)
|
|
2861
|
+
return "knowledgeGraph";
|
|
2862
|
+
if ("view" in r)
|
|
2863
|
+
return "view";
|
|
2864
|
+
throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.");
|
|
2865
|
+
}
|
|
2853
2866
|
class Nn {
|
|
2854
2867
|
constructor(t) {
|
|
2855
2868
|
this.dataModel = t, this.kind = "GraphQueryGenerationRequest", this.explainQuery = !0, this.schemaInformation = ae.fromDataModel(t);
|
|
@@ -2867,7 +2880,7 @@ class ae {
|
|
|
2867
2880
|
static fromDataModel(t) {
|
|
2868
2881
|
const r = new ae();
|
|
2869
2882
|
for (const a of t.entityTypes)
|
|
2870
|
-
r.entityTypes.push(
|
|
2883
|
+
r.entityTypes.push(W.fromEntityType(a));
|
|
2871
2884
|
for (const a of t.relationshipTypes)
|
|
2872
2885
|
r.relationshipTypes.push(An.fromRelationshipType(a));
|
|
2873
2886
|
return r.identifierInfo = {
|
|
@@ -2886,12 +2899,12 @@ class ae {
|
|
|
2886
2899
|
Relationship Types: ${a}.`;
|
|
2887
2900
|
}
|
|
2888
2901
|
}
|
|
2889
|
-
class
|
|
2902
|
+
class W {
|
|
2890
2903
|
constructor() {
|
|
2891
2904
|
this.name = "", this.properties = [];
|
|
2892
2905
|
}
|
|
2893
2906
|
static fromEntityType(t) {
|
|
2894
|
-
const r = new
|
|
2907
|
+
const r = new W();
|
|
2895
2908
|
r.name = t.name, r.alias = t.alias ? t.alias : void 0, r.role = zn(t.role);
|
|
2896
2909
|
for (const a of t.properties) {
|
|
2897
2910
|
const o = {
|
|
@@ -2910,12 +2923,12 @@ class K {
|
|
|
2910
2923
|
return r;
|
|
2911
2924
|
}
|
|
2912
2925
|
}
|
|
2913
|
-
class An extends
|
|
2926
|
+
class An extends W {
|
|
2914
2927
|
constructor() {
|
|
2915
2928
|
super(...arguments), this.observedEndPoints = [];
|
|
2916
2929
|
}
|
|
2917
2930
|
static fromRelationshipType(t) {
|
|
2918
|
-
const r =
|
|
2931
|
+
const r = W.fromEntityType(t);
|
|
2919
2932
|
r.observedEndPoints = [];
|
|
2920
2933
|
for (const a of t.endPoints)
|
|
2921
2934
|
r.observedEndPoints.push({
|
|
@@ -3318,7 +3331,7 @@ async function Bn(e, t, r, a, o) {
|
|
|
3318
3331
|
text: `Query Results parsed into ${u.length} unique relationships and entities. Atempting to add to link chart...`
|
|
3319
3332
|
},
|
|
3320
3333
|
o
|
|
3321
|
-
), !
|
|
3334
|
+
), !O(n) && n?.map) {
|
|
3322
3335
|
const p = n.map;
|
|
3323
3336
|
return await p.addRecords(u), n.goTo(p.diagramNodesExtent ?? new Le()), `Link Chart updated successfully. Cypher Query used:
|
|
3324
3337
|
${i}
|
|
@@ -3335,9 +3348,9 @@ Explanation: ${c}`;
|
|
|
3335
3348
|
const rt = "addRecords", Hn = l.object({
|
|
3336
3349
|
prompt: l.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
|
|
3337
3350
|
}), Zn = async ({ prompt: e }, t) => {
|
|
3338
|
-
const { knowledgeGraph: r } = await
|
|
3351
|
+
const { knowledgeGraph: r } = await V(t), a = re(t), { view: o } = a, s = _.getDefault().helperServices;
|
|
3339
3352
|
let i = e;
|
|
3340
|
-
if (
|
|
3353
|
+
if (O(o)) {
|
|
3341
3354
|
const d = o.map, { allNamedTypesFullyDynamic: u, idTypePairs: p, dynamicTypes: h } = Un(d), g = await R("arcgis_knowledge_current_map_context");
|
|
3342
3355
|
if (i = `${e}
|
|
3343
3356
|
|
|
@@ -3371,7 +3384,7 @@ ${u}${JSON.stringify(p)}`;
|
|
|
3371
3384
|
async function Yn(e, t) {
|
|
3372
3385
|
return await t.map?.applyLayout(e), `Successfully applied layout: ${e}.`;
|
|
3373
3386
|
}
|
|
3374
|
-
const
|
|
3387
|
+
const ie = "applyLayout", Xn = l.object({
|
|
3375
3388
|
layout: l.enum([
|
|
3376
3389
|
"organic-standard",
|
|
3377
3390
|
"organic-community",
|
|
@@ -3387,9 +3400,9 @@ const le = "applyLayout", Xn = l.object({
|
|
|
3387
3400
|
)
|
|
3388
3401
|
}), es = async ({ layout: e }, t) => {
|
|
3389
3402
|
const { view: r } = re(t);
|
|
3390
|
-
if (
|
|
3403
|
+
if (O(r))
|
|
3391
3404
|
return {
|
|
3392
|
-
toolName:
|
|
3405
|
+
toolName: ie,
|
|
3393
3406
|
status: "error",
|
|
3394
3407
|
errorMessage: "The applyLayout tool can only be used with a LinkChartView.",
|
|
3395
3408
|
error: new Error()
|
|
@@ -3397,26 +3410,26 @@ const le = "applyLayout", Xn = l.object({
|
|
|
3397
3410
|
{
|
|
3398
3411
|
const a = await Yn(e, r);
|
|
3399
3412
|
return {
|
|
3400
|
-
toolName:
|
|
3413
|
+
toolName: ie,
|
|
3401
3414
|
status: "success",
|
|
3402
3415
|
summary: a
|
|
3403
3416
|
};
|
|
3404
3417
|
}
|
|
3405
3418
|
}, ts = b(es, {
|
|
3406
|
-
name:
|
|
3419
|
+
name: ie,
|
|
3407
3420
|
description: "Apply a diagram layout to the link chart",
|
|
3408
3421
|
schema: Xn
|
|
3409
3422
|
});
|
|
3410
3423
|
function rs(e, t) {
|
|
3411
3424
|
return t.map?.changeNonspatialDataDisplay(e), `Successfully applied nonspatial visibility setting: ${e}.`;
|
|
3412
3425
|
}
|
|
3413
|
-
const
|
|
3426
|
+
const le = "changeNonspatialVisibility", as = l.object({
|
|
3414
3427
|
setting: l.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
|
|
3415
3428
|
}), os = async ({ setting: e }, t) => {
|
|
3416
3429
|
const { view: r } = re(t);
|
|
3417
|
-
if (
|
|
3430
|
+
if (O(r))
|
|
3418
3431
|
return {
|
|
3419
|
-
toolName:
|
|
3432
|
+
toolName: le,
|
|
3420
3433
|
status: "error",
|
|
3421
3434
|
errorMessage: "The changeNonspatialVisibility tool can only be used with a LinkChartView.",
|
|
3422
3435
|
error: new Error()
|
|
@@ -3424,13 +3437,13 @@ const ce = "changeNonspatialVisibility", as = l.object({
|
|
|
3424
3437
|
{
|
|
3425
3438
|
const a = rs(e, r);
|
|
3426
3439
|
return {
|
|
3427
|
-
toolName:
|
|
3440
|
+
toolName: le,
|
|
3428
3441
|
status: "success",
|
|
3429
3442
|
summary: a
|
|
3430
3443
|
};
|
|
3431
3444
|
}
|
|
3432
3445
|
}, ns = b(os, {
|
|
3433
|
-
name:
|
|
3446
|
+
name: le,
|
|
3434
3447
|
description: "Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",
|
|
3435
3448
|
schema: as
|
|
3436
3449
|
});
|
|
@@ -3473,15 +3486,15 @@ Explanation: ${c}`;
|
|
|
3473
3486
|
}
|
|
3474
3487
|
throw new Error(`Failed to create link chart after ${z} attempts.`);
|
|
3475
3488
|
}
|
|
3476
|
-
const
|
|
3489
|
+
const ce = "createLinkChart", is = l.object({
|
|
3477
3490
|
prompt: l.string().describe(
|
|
3478
3491
|
"The user's inquiry into the knowledge graph that needs to be transformed into a link chart visualization."
|
|
3479
3492
|
)
|
|
3480
3493
|
}), ls = async ({ prompt: e }, t) => {
|
|
3481
|
-
const { knowledgeGraph: r } = await
|
|
3482
|
-
if (
|
|
3494
|
+
const { knowledgeGraph: r } = await V(t), { view: a } = re(t);
|
|
3495
|
+
if (O(a))
|
|
3483
3496
|
return {
|
|
3484
|
-
toolName:
|
|
3497
|
+
toolName: ce,
|
|
3485
3498
|
status: "error",
|
|
3486
3499
|
errorMessage: "The createLinkChart tool can only be used with a LinkChartView.",
|
|
3487
3500
|
error: new Error()
|
|
@@ -3495,13 +3508,13 @@ const de = "createLinkChart", is = l.object({
|
|
|
3495
3508
|
t
|
|
3496
3509
|
);
|
|
3497
3510
|
return {
|
|
3498
|
-
toolName:
|
|
3511
|
+
toolName: ce,
|
|
3499
3512
|
status: "success",
|
|
3500
3513
|
summary: s
|
|
3501
3514
|
};
|
|
3502
3515
|
}
|
|
3503
3516
|
}, cs = b(ls, {
|
|
3504
|
-
name:
|
|
3517
|
+
name: ce,
|
|
3505
3518
|
description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",
|
|
3506
3519
|
schema: is
|
|
3507
3520
|
}), at = "queryGraphData", ds = l.object({
|
|
@@ -3513,7 +3526,7 @@ REQUEST LIMIT: If the user does not specifically request for no limits or an exp
|
|
|
3513
3526
|
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.`
|
|
3514
3527
|
)
|
|
3515
3528
|
}), us = async ({ prompt: e }, t) => {
|
|
3516
|
-
const { knowledgeGraph: r } = await
|
|
3529
|
+
const { knowledgeGraph: r } = await V(t), o = _.getDefault().helperServices, n = await tt({
|
|
3517
3530
|
prompt: e,
|
|
3518
3531
|
kg: r,
|
|
3519
3532
|
graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -3571,7 +3584,7 @@ ${p.length > u ? `Showing top ${u} results:
|
|
|
3571
3584
|
}), ot = "generateCypher", hs = l.object({
|
|
3572
3585
|
prompt: l.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
|
|
3573
3586
|
}), ms = async ({ prompt: e }, t) => {
|
|
3574
|
-
const { knowledgeGraph: r } = await
|
|
3587
|
+
const { knowledgeGraph: r } = await V(t), o = _.getDefault().helperServices, n = await jn(
|
|
3575
3588
|
e,
|
|
3576
3589
|
r.dataModel,
|
|
3577
3590
|
`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
|
|
@@ -3632,7 +3645,7 @@ const nt = "searchGraphData", ws = l.object({
|
|
|
3632
3645
|
"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."
|
|
3633
3646
|
)
|
|
3634
3647
|
}), bs = async ({ prompt: e }, t) => {
|
|
3635
|
-
const { knowledgeGraph: r } = await
|
|
3648
|
+
const { knowledgeGraph: r } = await V(t);
|
|
3636
3649
|
await m({ text: "Generating search query for the user inquiry" }, t);
|
|
3637
3650
|
const a = await fs(e, r);
|
|
3638
3651
|
await m({ text: "Executing graph search with generated search query" }, t);
|
|
@@ -3693,22 +3706,28 @@ const nt = "searchGraphData", ws = l.object({
|
|
|
3693
3706
|
ps
|
|
3694
3707
|
];
|
|
3695
3708
|
async function vs(e, t) {
|
|
3696
|
-
const r = await R("arcgis_knowledge_tool_prompt"), a = {
|
|
3709
|
+
const r = await R("arcgis_knowledge_tool_prompt"), a = In(t), o = {
|
|
3697
3710
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
3698
3711
|
userRequest: e.agentExecutionContext.userRequest,
|
|
3699
|
-
priorSteps: e.agentExecutionContext.priorSteps
|
|
3700
|
-
|
|
3712
|
+
priorSteps: e.agentExecutionContext.priorSteps,
|
|
3713
|
+
contextType: a
|
|
3714
|
+
}, n = await P({
|
|
3701
3715
|
promptText: r,
|
|
3702
3716
|
messages: e.arcgisKnowledgeMessages,
|
|
3703
|
-
inputVariables:
|
|
3717
|
+
inputVariables: o,
|
|
3704
3718
|
tools: st
|
|
3705
|
-
}),
|
|
3706
|
-
return {
|
|
3719
|
+
}), s = (n.tool_calls?.length ?? 0) > 0, i = typeof n.text == "string" ? n.text.trim() : "", c = i.length > 0, d = n.content.toString();
|
|
3720
|
+
return !s && (a === "map" || a === "knowledgeGraph") ? {
|
|
3721
|
+
...e,
|
|
3722
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, n],
|
|
3723
|
+
outputMessage: a === "map" ? "No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries." : "No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",
|
|
3724
|
+
status: "success"
|
|
3725
|
+
} : {
|
|
3707
3726
|
...e,
|
|
3708
|
-
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages,
|
|
3709
|
-
outputMessage:
|
|
3710
|
-
status:
|
|
3711
|
-
summary:
|
|
3727
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, n],
|
|
3728
|
+
outputMessage: s ? d : i,
|
|
3729
|
+
status: s ? e.status : c ? "success" : "failed",
|
|
3730
|
+
summary: d ? N(d) : "ArcGIS Knowledge Agent tool executed."
|
|
3712
3731
|
};
|
|
3713
3732
|
}
|
|
3714
3733
|
async function xs(e, t) {
|
|
@@ -3764,14 +3783,14 @@ async function xs(e, t) {
|
|
|
3764
3783
|
}
|
|
3765
3784
|
const Ts = (e, t) => (
|
|
3766
3785
|
//agent services (ex: embeddingsWorker) would go in the array below, if required.
|
|
3767
|
-
|
|
3786
|
+
H([], "ArcgisKnowledge Agent")(e, t)
|
|
3768
3787
|
);
|
|
3769
3788
|
async function Es(e, t) {
|
|
3770
3789
|
const a = (e.arcgisKnowledgeToolResult ?? []).map((d) => ({
|
|
3771
3790
|
...d,
|
|
3772
3791
|
details: void 0
|
|
3773
3792
|
// Remove details to avoid overwhelming the LLM with too much info
|
|
3774
|
-
})), { knowledgeGraph: o } = await
|
|
3793
|
+
})), { knowledgeGraph: o } = await V(t), n = ae.getDataModelTypesSummary(o.dataModel), s = {
|
|
3775
3794
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
3776
3795
|
userRequest: e.agentExecutionContext.userRequest,
|
|
3777
3796
|
toolResult: a,
|
|
@@ -3789,7 +3808,7 @@ async function Es(e, t) {
|
|
|
3789
3808
|
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new ze(c)]
|
|
3790
3809
|
};
|
|
3791
3810
|
}
|
|
3792
|
-
const Rs = () => new
|
|
3811
|
+
const Rs = () => new U(Ye).addNode("requireArcgisKnowledgeServices", Ts).addNode("agent", vs).addNode("tools", xs).addNode("summarizationLLM", Es).addEdge(B, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (t) => (t.arcgisKnowledgeMessages[t.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : C).addConditionalEdges("tools", (t) => t.status === "failed" ? C : "summarizationLLM").addEdge("summarizationLLM", C), $s = String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
|
|
3793
3812
|
This agent has two categories of skills: those that work with an active link chart visualization of a subset of the data in the knowledge graph, and those that work with the knowledge graph data more generally against the entire dataset in the service and database.
|
|
3794
3813
|
For link charts, the agent enables users to interact with a link chart by adding new entities (also called nodes) or relationships (also called edges), removing existing entities or relationships,
|
|
3795
3814
|
expanding the graph from particular entities, finding relationships between specified entities on the link chart and adding them to the link chart, finding all relationships
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/ai-agents",
|
|
3
|
-
"version": "5.1.0-next.
|
|
3
|
+
"version": "5.1.0-next.111",
|
|
4
4
|
"description": "ArcGIS AI Agents Package",
|
|
5
5
|
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@langchain/langgraph": "^1.2.6",
|
|
21
21
|
"tslib": "^2.8.1",
|
|
22
22
|
"zod": "^4.3.6",
|
|
23
|
-
"@arcgis/ai-orchestrator": "5.1.0-next.
|
|
23
|
+
"@arcgis/ai-orchestrator": "5.1.0-next.111"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@arcgis/core": "^5.1.0-next"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const e = `# ArcgisKnowledge Tool Instructions
|
|
2
|
-
|
|
3
|
-
You are an assistant that helps users answer questions and perform operations on their knowledge graph or link chart. You have been assigned the task below, which must be achieved by calling a single tool.
|
|
4
|
-
|
|
5
|
-
## Task Details:
|
|
6
|
-
|
|
7
|
-
Assigned task:
|
|
8
|
-
{assignedTask}
|
|
9
|
-
|
|
10
|
-
User Request:
|
|
11
|
-
{userRequest}
|
|
12
|
-
|
|
13
|
-
Prior steps:
|
|
14
|
-
{priorSteps}
|
|
15
|
-
|
|
16
|
-
## Your Goal:
|
|
17
|
-
|
|
18
|
-
Call exactly one arcgisKnowledge tool, with the appropriate arguments given the assigned task. Use the provided user request or prior steps only if needed for context based on the assigned task.
|
|
19
|
-
|
|
20
|
-
If no tools apply, return an **empty string**
|
|
21
|
-
|
|
22
|
-
CRITICAL: You are FORBIDDEN from making multiple tool calls. You MUST make exactly ONE tool call.
|
|
23
|
-
`;
|
|
24
|
-
export {
|
|
25
|
-
e as default
|
|
26
|
-
};
|