@arcgis/ai-components 5.1.0-next.130 → 5.1.0-next.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +99 -0
- package/dist/agent-utils/index.js +148 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +30 -1
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/cdn/2DYXX3VX.js +2 -0
- package/dist/cdn/4ASZF5I2.js +181 -0
- package/dist/cdn/6FEB6XYK.js +2 -0
- package/dist/cdn/7HKOEG6B.js +161 -0
- package/dist/cdn/DAMZY3V4.js +2 -0
- package/dist/cdn/DZWRIK64.js +47 -0
- package/dist/cdn/EY5GGKO5.js +2 -0
- package/dist/cdn/FYNHAVHL.js +2 -0
- package/dist/cdn/GNCV7JCL.js +2 -0
- package/dist/cdn/H3EEFM4A.js +179 -0
- package/dist/cdn/I6AHJA2A.js +16 -0
- package/dist/cdn/IFDBNTW2.js +3 -0
- package/dist/cdn/KGYSBUFO.js +9 -0
- package/dist/cdn/KJ5IHMRP.js +2 -0
- package/dist/cdn/L6GVMINQ.js +2 -0
- package/dist/cdn/LXJWWOGK.js +66 -0
- package/dist/cdn/MDZ3PTNT.js +2 -0
- package/dist/cdn/{RBMBKUY6.js → MGPLH2PO.js} +5 -5
- package/dist/cdn/{Y2L6M2RG.js → NKL6PVCN.js} +11 -11
- package/dist/cdn/O4SVTPFW.js +2 -0
- package/dist/cdn/{LUWP3MUX.js → P3JUCFXI.js} +16 -0
- package/dist/cdn/PCZS64LS.js +2 -0
- package/dist/cdn/PIUDMACH.js +56 -0
- package/dist/cdn/QH6TSBNI.js +2 -0
- package/dist/cdn/{FKSLZTUY.js → QXWL4WLO.js} +5 -5
- package/dist/cdn/QZXQIJSW.js +2 -0
- package/dist/cdn/RLWXD365.js +2 -0
- package/dist/cdn/UPSGN34Q.js +2 -0
- package/dist/cdn/V746CPCO.js +6 -0
- package/dist/cdn/VPZHLYPA.js +2 -0
- package/dist/cdn/VWG4M6ZB.js +2 -0
- package/dist/cdn/{72HM6DTZ.js → WRKGKKWT.js} +3 -3
- package/dist/cdn/ZL2D2BJI.js +2 -0
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1046 -1018
- package/dist/chunks/arcgisKnowledgeGraph.js +66 -46
- package/dist/chunks/dataExplorationGraph.js +8 -3
- package/dist/chunks/generateLayerDescriptions.js +228 -217
- package/dist/chunks/helpGraph.js +14 -11
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +25 -22
- package/dist/chunks/navigationGraph.js +7 -3
- package/dist/chunks/orchestrator.js +9 -8
- package/dist/chunks/toolCallResponse.js +5 -3
- package/dist/components/arcgis-assistant/customElement.js +1 -0
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-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/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +48 -47
- package/package.json +5 -4
- package/dist/cdn/AZTWZFVA.js +0 -16
- package/dist/cdn/I3H52G4C.js +0 -2
- package/dist/cdn/QLU3NT5J.js +0 -2
- package/dist/cdn/RJ6XMESZ.js +0 -165
- package/dist/cdn/V7BWJN43.js +0 -422
- package/dist/cdn/ZP3SG5OG.js +0 -108
- package/dist/cdn/ZSLJX22Z.js +0 -3
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { StateGraph as
|
|
3
|
-
import { a as
|
|
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 as S, g as u, h as q, t as c, r as M, 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 {
|
|
6
|
+
import { h as G, e as N } from "./generateLayerDescriptions.js";
|
|
7
7
|
import { AIMessage as R } from "@langchain/core/messages";
|
|
8
8
|
import "@langchain/core/callbacks/dispatch/web";
|
|
9
9
|
import "@langchain/openai";
|
|
10
|
+
import "@arcgis/core/config.js";
|
|
10
11
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
11
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
12
13
|
import "@arcgis/core/request.js";
|
|
13
|
-
import { ToolNode as
|
|
14
|
+
import { ToolNode as L } from "@langchain/langgraph/prebuilt";
|
|
15
|
+
import { s as p, a as D } from "./index.js";
|
|
14
16
|
import "@langchain/core/prompts";
|
|
15
17
|
const w = [
|
|
16
|
-
k,
|
|
17
|
-
_,
|
|
18
18
|
b,
|
|
19
|
+
_,
|
|
19
20
|
K,
|
|
20
21
|
A,
|
|
22
|
+
T,
|
|
21
23
|
v,
|
|
22
|
-
|
|
24
|
+
S
|
|
23
25
|
];
|
|
24
|
-
async function
|
|
25
|
-
const i = await u("arcgis_knowledge_tool_prompt"), o =
|
|
26
|
+
async function z(e, a) {
|
|
27
|
+
const i = await u("arcgis_knowledge_tool_prompt"), o = q(a), n = {
|
|
26
28
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
27
29
|
userRequest: e.agentExecutionContext.userRequest,
|
|
28
30
|
priorSteps: e.agentExecutionContext.priorSteps,
|
|
29
31
|
contextType: o
|
|
30
|
-
}, s = await
|
|
32
|
+
}, s = await G({
|
|
31
33
|
promptText: i,
|
|
32
34
|
messages: e.arcgisKnowledgeMessages,
|
|
33
|
-
inputVariables:
|
|
35
|
+
inputVariables: n,
|
|
34
36
|
tools: w
|
|
35
|
-
}),
|
|
36
|
-
return !
|
|
37
|
+
}), l = (s.tool_calls?.length ?? 0) > 0, t = typeof s.text == "string" ? s.text.trim() : "", r = t.length > 0, d = s.content.toString();
|
|
38
|
+
return !l && (o === "map" || o === "knowledgeGraph") ? {
|
|
37
39
|
...e,
|
|
38
40
|
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, s],
|
|
39
41
|
outputMessage: o === "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.",
|
|
@@ -41,26 +43,44 @@ async function L(e, a) {
|
|
|
41
43
|
} : {
|
|
42
44
|
...e,
|
|
43
45
|
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, s],
|
|
44
|
-
outputMessage:
|
|
45
|
-
status:
|
|
46
|
+
outputMessage: l ? d : t,
|
|
47
|
+
status: l ? e.status : r ? "success" : "failed",
|
|
46
48
|
summary: d ? c(d) : "ArcGIS Knowledge Agent tool executed."
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const y = {
|
|
52
|
+
generateCypher: "generated-cypher-query",
|
|
53
|
+
queryGraphData: "graph-query-result",
|
|
54
|
+
searchGraphData: "graph-search-result",
|
|
55
|
+
addRecords: "added-records",
|
|
56
|
+
applyLayout: "applied-layout",
|
|
57
|
+
changeNonspatialVisibility: "changed-nonspatial-visibility",
|
|
58
|
+
createLinkChart: "created-link-chart"
|
|
59
|
+
};
|
|
60
|
+
function F(e) {
|
|
61
|
+
return !!e && e.status === "success" && !!y[e.toolName];
|
|
62
|
+
}
|
|
63
|
+
function $(e) {
|
|
64
|
+
return {
|
|
65
|
+
type: y[e.toolName],
|
|
66
|
+
data: e.details
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function I(e, a) {
|
|
70
|
+
const i = new L(w, { handleToolErrors: !1 });
|
|
51
71
|
try {
|
|
52
72
|
const o = await i.invoke(
|
|
53
73
|
{
|
|
54
74
|
messages: e.arcgisKnowledgeMessages
|
|
55
75
|
},
|
|
56
76
|
a
|
|
57
|
-
),
|
|
77
|
+
), n = [];
|
|
58
78
|
for (const t of o.messages) {
|
|
59
|
-
let
|
|
79
|
+
let r;
|
|
60
80
|
if (typeof t.content != "string")
|
|
61
81
|
throw new Error(`Unexpected tool message content type: ${typeof t.content}. Expected string.`);
|
|
62
82
|
try {
|
|
63
|
-
|
|
83
|
+
r = JSON.parse(t.content);
|
|
64
84
|
} catch {
|
|
65
85
|
throw new Error(
|
|
66
86
|
`Failed to parse tool message content as JSON. Tool: ${t.name ?? "unknown"}.
|
|
@@ -68,11 +88,11 @@ async function z(e, a) {
|
|
|
68
88
|
Original Content: ${t.content}`
|
|
69
89
|
);
|
|
70
90
|
}
|
|
71
|
-
if (!
|
|
91
|
+
if (!r || typeof r != "object" || !("toolName" in r))
|
|
72
92
|
throw new Error(
|
|
73
|
-
`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(
|
|
93
|
+
`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(r)}`
|
|
74
94
|
);
|
|
75
|
-
|
|
95
|
+
n.push(r);
|
|
76
96
|
}
|
|
77
97
|
await p(
|
|
78
98
|
{
|
|
@@ -80,59 +100,59 @@ async function z(e, a) {
|
|
|
80
100
|
},
|
|
81
101
|
a
|
|
82
102
|
);
|
|
83
|
-
const s =
|
|
84
|
-
return {
|
|
103
|
+
const s = n.filter((t) => typeof t != "string").map((t) => `- Called Tool: ${t.toolName}, Status: ${t.status}`), l = n[0];
|
|
104
|
+
return l && F(l) && await D($(l), a), {
|
|
85
105
|
...e,
|
|
86
106
|
outputMessage: s.join(`
|
|
87
107
|
`),
|
|
88
108
|
summary: s.length ? c(s.join(`
|
|
89
109
|
`)) : "ArcGIS Knowledge Agent did not execute any tools or return any results.",
|
|
90
110
|
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, ...o.messages],
|
|
91
|
-
arcgisKnowledgeToolResult:
|
|
111
|
+
arcgisKnowledgeToolResult: n
|
|
92
112
|
};
|
|
93
113
|
} catch (o) {
|
|
94
|
-
const
|
|
114
|
+
const n = o instanceof Error ? o.message : String(o);
|
|
95
115
|
return await p(
|
|
96
|
-
{ text: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${
|
|
116
|
+
{ text: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}` },
|
|
97
117
|
a
|
|
98
118
|
), {
|
|
99
119
|
...e,
|
|
100
|
-
outputMessage: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${
|
|
120
|
+
outputMessage: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`,
|
|
101
121
|
status: "failed",
|
|
102
|
-
summary: c(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${
|
|
122
|
+
summary: c(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),
|
|
103
123
|
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages]
|
|
104
124
|
};
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
|
-
const
|
|
127
|
+
const V = (e, a) => (
|
|
108
128
|
//agent services (ex: embeddingsWorker) would go in the array below, if required.
|
|
109
|
-
|
|
129
|
+
M([], "ArcgisKnowledge Agent")(e, a)
|
|
110
130
|
);
|
|
111
|
-
async function
|
|
131
|
+
async function j(e, a) {
|
|
112
132
|
const o = (e.arcgisKnowledgeToolResult ?? []).map((d) => ({
|
|
113
133
|
...d,
|
|
114
134
|
details: void 0
|
|
115
135
|
// Remove details to avoid overwhelming the LLM with too much info
|
|
116
|
-
})), { knowledgeGraph:
|
|
136
|
+
})), { knowledgeGraph: n } = await C(a), s = E.getDataModelTypesSummary(n.dataModel), l = {
|
|
117
137
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
118
138
|
userRequest: e.agentExecutionContext.userRequest,
|
|
119
139
|
toolResult: o,
|
|
120
140
|
dataModelSummary: s
|
|
121
|
-
},
|
|
141
|
+
}, t = await N({
|
|
122
142
|
promptText: await u("arcgis_knowledge_summarize_result_prompt"),
|
|
123
143
|
modelTier: "default",
|
|
124
|
-
inputVariables:
|
|
125
|
-
}),
|
|
144
|
+
inputVariables: l
|
|
145
|
+
}), r = typeof t == "string" ? t : t.content;
|
|
126
146
|
return {
|
|
127
147
|
...e,
|
|
128
|
-
outputMessage:
|
|
148
|
+
outputMessage: r,
|
|
129
149
|
status: "success",
|
|
130
|
-
summary: c(
|
|
131
|
-
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new R(
|
|
150
|
+
summary: c(r),
|
|
151
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new R(r)]
|
|
132
152
|
};
|
|
133
153
|
}
|
|
134
154
|
function g(e) {
|
|
135
|
-
return async (a, i) => i?.configurable?.abortSignal?.aborted ? (await p({ text: "Knowledge Agent execution cancelled" }, i), new
|
|
155
|
+
return async (a, i) => i?.configurable?.abortSignal?.aborted ? (await p({ text: "Knowledge Agent execution cancelled" }, i), new k({
|
|
136
156
|
goto: h,
|
|
137
157
|
update: {
|
|
138
158
|
outputMessage: "Knowledge Agent execution cancelled",
|
|
@@ -141,7 +161,7 @@ function g(e) {
|
|
|
141
161
|
}
|
|
142
162
|
})) : await e(a, i);
|
|
143
163
|
}
|
|
144
|
-
const
|
|
164
|
+
const O = () => new f(m).addNode("requireArcgisKnowledgeServices", V).addNode("agent", g(z)).addNode("tools", g(I)).addNode("summarizationLLM", g(j)).addEdge(x, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (a) => (a.arcgisKnowledgeMessages[a.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : h).addConditionalEdges("tools", (a) => a.status === "failed" ? h : "summarizationLLM").addEdge("summarizationLLM", h), P = 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).
|
|
145
165
|
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.
|
|
146
166
|
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,
|
|
147
167
|
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
|
|
@@ -179,13 +199,13 @@ _example: "Discover and add all the relationships originating at 'Entity E' to t
|
|
|
179
199
|
_example: "Show me all entities with a name similar to 'Smith' and add them to the link chart"_
|
|
180
200
|
_example: "Find reports in my graph that have a title similar to 'Quarterly Earnings'"_
|
|
181
201
|
_example: "Find John Smith and all people he has made phone calls to in the last year"_
|
|
182
|
-
_example: "What is the average age of all people who work for Esri?"_`,
|
|
202
|
+
_example: "What is the average age of all people who work for Esri?"_`, re = {
|
|
183
203
|
id: "arcgisKnowledge",
|
|
184
204
|
name: "ArcgisKnowledge Agent",
|
|
185
|
-
description:
|
|
186
|
-
createGraph:
|
|
205
|
+
description: P,
|
|
206
|
+
createGraph: O,
|
|
187
207
|
workspace: m
|
|
188
208
|
};
|
|
189
209
|
export {
|
|
190
|
-
|
|
210
|
+
re as A
|
|
191
211
|
};
|
|
@@ -3,9 +3,11 @@ import { StateGraph as I, START as k, END as v } from "@langchain/langgraph/web"
|
|
|
3
3
|
import { g as T, O as R, P as C, t as N, Q as V, f as h, R as D, r as z, S as b, T as P } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
|
-
import {
|
|
6
|
+
import { h as _, e as Q } from "./generateLayerDescriptions.js";
|
|
7
7
|
import { AIMessage as j } from "@langchain/core/messages";
|
|
8
|
+
import { s as n } from "./index.js";
|
|
8
9
|
import "@langchain/openai";
|
|
10
|
+
import "@arcgis/core/config.js";
|
|
9
11
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
10
12
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
11
13
|
import "@arcgis/core/request.js";
|
|
@@ -30,6 +32,7 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
30
32
|
}, r = await _({
|
|
31
33
|
promptText: d,
|
|
32
34
|
modelTier: "advanced",
|
|
35
|
+
config: e,
|
|
33
36
|
messages: t.dataExplorationMessages,
|
|
34
37
|
inputVariables: o,
|
|
35
38
|
tools: C
|
|
@@ -66,6 +69,7 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
66
69
|
}, p = await _({
|
|
67
70
|
promptText: d,
|
|
68
71
|
modelTier: "advanced",
|
|
72
|
+
config: e,
|
|
69
73
|
messages: t.dataExplorationMessages,
|
|
70
74
|
inputVariables: m,
|
|
71
75
|
tools: V
|
|
@@ -90,6 +94,7 @@ const W = async (t, e) => (await n({ text: "Exiting Data Exploration agent" }, e
|
|
|
90
94
|
}, s = await Q({
|
|
91
95
|
promptText: d,
|
|
92
96
|
modelTier: "fast",
|
|
97
|
+
config: e,
|
|
93
98
|
messages: t.dataExplorationMessages,
|
|
94
99
|
inputVariables: l
|
|
95
100
|
}), o = typeof s == "string" ? s : s.content, r = new j(o);
|
|
@@ -293,7 +298,7 @@ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text
|
|
|
293
298
|
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”). However, this agent does not handle addresses.
|
|
294
299
|
_Example: “How many features are there?”_
|
|
295
300
|
_Example: “What’s the average population?”_
|
|
296
|
-
_Example: “Which values are in the status field?”_`,
|
|
301
|
+
_Example: “Which values are in the status field?”_`, Re = {
|
|
297
302
|
id: "dataExploration",
|
|
298
303
|
name: "Data Exploration Agent",
|
|
299
304
|
description: de,
|
|
@@ -301,5 +306,5 @@ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text
|
|
|
301
306
|
workspace: b
|
|
302
307
|
};
|
|
303
308
|
export {
|
|
304
|
-
|
|
309
|
+
Re as D
|
|
305
310
|
};
|