@arcgis/ai-components 5.2.0-next.6 → 5.2.0-next.61
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/README.md +2 -2
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +2 -1
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -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 +36 -7
- 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/242OOJML.js +2 -0
- package/dist/cdn/275NKWUE.js +22 -0
- package/dist/cdn/2WDZIJQR.js +2 -0
- package/dist/cdn/2XQAM2Q3.js +4 -0
- package/dist/cdn/3DJDRAGV.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/3YCSUTGV.js +14 -0
- package/dist/cdn/3ZPPYCNL.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4CEMUECT.js +2 -0
- package/dist/cdn/57OMVTIU.js +2 -0
- package/dist/cdn/5L7VPEQM.js +2 -0
- package/dist/cdn/6U7TEAAJ.js +2 -0
- package/dist/cdn/7NP7WGR5.js +2 -0
- package/dist/cdn/AHLLB5QW.js +2 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/AYMUK2MC.js +36 -0
- package/dist/cdn/BE7ZN5FZ.js +2 -0
- package/dist/cdn/BI3LK5D3.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BSP6IJY4.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CWZEQ4R6.js +2 -0
- package/dist/cdn/{VOQX4AVB.js → FC45FF2D.js} +6 -4
- package/dist/cdn/FNPLHH4E.js +3 -0
- package/dist/cdn/FVDFPK3V.js +18 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/GLOALVJR.js +3 -0
- package/dist/cdn/HBLRVXEB.js +2 -0
- package/dist/cdn/HJG7QM2R.js +9 -0
- package/dist/cdn/HLO655UO.js +2 -0
- package/dist/cdn/HPSVZVAR.js +2 -0
- package/dist/cdn/HQXPPYMD.js +2 -0
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/ICYUPLZM.js +56 -0
- package/dist/cdn/IEHPNCTL.js +2 -0
- package/dist/cdn/IHP25JWI.js +99 -0
- package/dist/cdn/J6A4AS7E.js +22 -0
- package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
- package/dist/cdn/JHFOZPBP.js +2 -0
- package/dist/cdn/L4SS54EZ.js +2 -0
- package/dist/cdn/LHLO6PTD.js +2 -0
- package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LUJCH5V7.js +2 -0
- package/dist/cdn/LUY6V4TP.js +181 -0
- package/dist/cdn/M3MRIGDZ.js +2 -0
- package/dist/cdn/MSDNERUF.js +2 -0
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/NQROZZHC.js +65 -0
- package/dist/cdn/NSER3L4A.js +2 -0
- package/dist/cdn/OI7EGYZU.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OY2P2O47.js +180 -0
- package/dist/cdn/OYNIFMCJ.js +2 -0
- package/dist/cdn/PJ3UN2RU.js +2 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PVE7Q43N.js +2 -0
- package/dist/cdn/QBINZNXI.js +9 -0
- package/dist/cdn/QZLE7B6X.js +2 -0
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/RAAV47KU.js +3 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/SLXOVE7Y.js +2 -0
- package/dist/cdn/TFT6HK3O.js +208 -0
- package/dist/cdn/THXUE6R4.js +2 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/U4Z5XNJ5.js +2 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/{H7422XUG.js → VCXSQWGA.js} +1 -1
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/WHOZT5H5.js +48 -0
- package/dist/cdn/WY7B6IMH.js +2 -0
- package/dist/cdn/XCRR2EEG.js +6 -0
- package/dist/cdn/XVPBO2JC.js +2 -0
- package/dist/cdn/YHQJ66WJ.js +2 -0
- package/dist/cdn/ZS6SXJP2.js +2 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- 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 +1794 -1597
- package/dist/chunks/arcgisKnowledgeGraph.js +127 -72
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/converterUtils.js +39 -32
- package/dist/chunks/dataExplorationGraph.js +140 -114
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +239 -225
- package/dist/chunks/helpGraph.js +30 -23
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +25 -21
- package/dist/chunks/navigationGraph.js +70 -62
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +110 -108
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +13 -10
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +386 -152
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +12 -6
- package/dist/components/arcgis-assistant-help-agent/customElement.js +9 -3
- package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +18 -12
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-message/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +10 -10
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +12 -6
- package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +7 -6
- package/dist/oauth-callback.html +1 -1
- package/dist/types/lumina.d.ts +7 -6
- package/dist/types/preact.d.ts +7 -6
- package/dist/types/react.d.ts +7 -6
- package/dist/types/stencil.d.ts +7 -6
- package/dist/utils/index.d.ts +94 -47
- package/dist/utils/index.js +80 -65
- package/package.json +13 -12
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3NI46YCE.js +0 -2
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/47FWPQ2A.js +0 -16
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AEJHYRGT.js +0 -166
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/BFZJNJL6.js +0 -22
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GCQLVNNC.js +0 -14
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JV4SI65E.js +0 -108
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/R6HV42YW.js +0 -3
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V2P4AIGG.js +0 -2
- package/dist/cdn/V7OJRG26.js +0 -36
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
package/dist/chunks/helpGraph.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { StateGraph as d, START as g, END as i } from "@langchain/langgraph/web";
|
|
3
|
-
import { l as h, g as
|
|
3
|
+
import { l as h, g as f, f as p, r as x, t as y, H as u } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
|
-
import
|
|
6
|
+
import "@arcgis/core/request.js";
|
|
7
|
+
import "@arcgis/toolkit/string";
|
|
8
|
+
import { h as S } from "./generateLayerDescriptions.js";
|
|
7
9
|
import "@langchain/core/messages";
|
|
8
10
|
import "@langchain/core/callbacks/dispatch/web";
|
|
9
11
|
import "@langchain/openai";
|
|
12
|
+
import "@arcgis/core/config.js";
|
|
10
13
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
11
14
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
12
|
-
import "
|
|
13
|
-
import { ToolNode as
|
|
15
|
+
import { h as E } from "./toolCallResponse.js";
|
|
16
|
+
import { ToolNode as T } from "@langchain/langgraph/prebuilt";
|
|
17
|
+
import { s as m } from "./index.js";
|
|
14
18
|
import "@langchain/core/prompts";
|
|
15
|
-
const
|
|
19
|
+
const c = [h], v = (e) => {
|
|
16
20
|
if (!e || e.size === 0)
|
|
17
21
|
return "No layers available in this map.";
|
|
18
22
|
const t = Array.from(e.values()).map(({ layerItem: r, fieldRegistry: s }, l) => {
|
|
@@ -25,26 +29,29 @@ const m = [h], v = (e) => {
|
|
|
25
29
|
return `This map contains ${e.size} layer(s):
|
|
26
30
|
|
|
27
31
|
${t}`;
|
|
28
|
-
},
|
|
32
|
+
}, C = (e) => {
|
|
29
33
|
const t = e?.list() ?? [];
|
|
30
34
|
return t.length ? t.map((r) => `- ${r.agent.name}: ${r.agent.description}`).join(`
|
|
31
35
|
`) : "No agents currently available.";
|
|
32
36
|
};
|
|
33
37
|
async function _(e, t) {
|
|
34
|
-
const r = await
|
|
38
|
+
const r = await f("help_prompt"), s = p(t, "layersAndFieldsRegistry"), l = p(t, "agentRegistry");
|
|
35
39
|
try {
|
|
36
40
|
const a = await S({
|
|
37
41
|
promptText: r,
|
|
38
|
-
modelTier: "
|
|
39
|
-
|
|
42
|
+
modelTier: "default",
|
|
43
|
+
config: t,
|
|
44
|
+
tools: c,
|
|
40
45
|
inputVariables: {
|
|
41
46
|
layerSummary: v(s),
|
|
42
|
-
agents:
|
|
47
|
+
agents: C(l),
|
|
43
48
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
44
49
|
userRequest: e.agentExecutionContext.userRequest,
|
|
45
50
|
priorSteps: e.agentExecutionContext.priorSteps
|
|
46
51
|
}
|
|
47
|
-
})
|
|
52
|
+
});
|
|
53
|
+
await E(a, t);
|
|
54
|
+
const o = (a.tool_calls?.length ?? 0) > 0, n = typeof a.text == "string" ? a.text.trim() : "";
|
|
48
55
|
return {
|
|
49
56
|
...e,
|
|
50
57
|
helpInternalState: {
|
|
@@ -65,16 +72,16 @@ async function _(e, t) {
|
|
|
65
72
|
};
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
|
-
const
|
|
69
|
-
async function
|
|
70
|
-
const r = new
|
|
75
|
+
const H = (e, t) => x(["agentRegistry"], "Help Agent")(e, t);
|
|
76
|
+
async function b(e, t) {
|
|
77
|
+
const r = new T(c, { handleToolErrors: !1 });
|
|
71
78
|
try {
|
|
72
79
|
const s = e.helpInternalState.toolCallMessage;
|
|
73
80
|
if (!s)
|
|
74
81
|
throw new Error("helpToolCalling: missing helpInternalState.toolCallMessage");
|
|
75
82
|
const a = (await r.invoke({ messages: [s] }, t)).messages.map((o) => o.text).join(`
|
|
76
83
|
`);
|
|
77
|
-
return await
|
|
84
|
+
return await m({ text: `Finished executing help tool: ${a}` }, t), {
|
|
78
85
|
...e,
|
|
79
86
|
outputMessage: a,
|
|
80
87
|
status: "success",
|
|
@@ -86,7 +93,7 @@ async function H(e, t) {
|
|
|
86
93
|
};
|
|
87
94
|
} catch (s) {
|
|
88
95
|
const l = s instanceof Error ? s.message : String(s);
|
|
89
|
-
return await
|
|
96
|
+
return await m({ text: `Help tool execution failed: ${l}` }, t), {
|
|
90
97
|
...e,
|
|
91
98
|
outputMessage: `Help tool execution failed: ${l}`,
|
|
92
99
|
status: "failed",
|
|
@@ -98,7 +105,7 @@ async function H(e, t) {
|
|
|
98
105
|
};
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
|
-
const
|
|
108
|
+
const M = () => new d(u).addNode("requireHelpServices", H).addNode("agent", _).addNode("tools", b).addEdge(g, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => t.helpInternalState.toolCallMessage ? "tools" : i).addEdge("tools", i), k = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
|
|
102
109
|
|
|
103
110
|
_Example: “Tell me about this map”_
|
|
104
111
|
_Example: “List all layers in this map”_
|
|
@@ -107,17 +114,17 @@ const b = () => new d(u).addNode("requireHelpServices", C).addNode("agent", _).a
|
|
|
107
114
|
_Example: “What can you do?”_
|
|
108
115
|
_Example: “What can I ask”_
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
If the user asks unrelated queries like "What are the vowels in English alphabet" or "How to cook", call this agent so it can politely refuse and redirect to map-related questions.
|
|
111
118
|
|
|
112
|
-
IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond
|
|
119
|
+
IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond that the requested action is not supported.
|
|
113
120
|
_Example: "Create a chart"_
|
|
114
|
-
_Example: "Create a table"_`,
|
|
121
|
+
_Example: "Create a table"_`, J = {
|
|
115
122
|
id: "help",
|
|
116
123
|
name: "Help Agent",
|
|
117
|
-
description:
|
|
118
|
-
createGraph:
|
|
124
|
+
description: k,
|
|
125
|
+
createGraph: M,
|
|
119
126
|
workspace: u
|
|
120
127
|
};
|
|
121
128
|
export {
|
|
122
|
-
|
|
129
|
+
J as H
|
|
123
130
|
};
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const
|
|
2
|
+
const n = `## Who you are
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
You are a map assistant embedded inside a GIS application. You have no knowledge of history, science, people, events, cooking, or anything outside of this map and its data. You only know what is described in the Map Context below.
|
|
5
|
+
|
|
6
|
+
If asked anything outside of that context, you simply don't have that information — respond naturally and redirect to something you _can_ help with, using specific layer and field names from the map context.
|
|
7
|
+
|
|
8
|
+
Example of how to handle unknown topics:
|
|
9
|
+
"I don't have information on that — I only know about this map. You could ask me to list all layers in the map, or capabilities of this assistant."
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Your capabilities
|
|
14
|
+
|
|
15
|
+
You can help users with:
|
|
16
|
+
|
|
17
|
+
- Listing the layers in this map
|
|
18
|
+
- Listing the fields in a specific layer (use the tool)
|
|
19
|
+
- Suggesting specific queries using actual layer and field names
|
|
20
|
+
- Summarizing what this map contains and what users can do with it
|
|
21
|
+
- Letting users know when a map-related action isn't supported (e.g. charts, tables), and that it may be added in the future
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Input
|
|
5
26
|
|
|
6
27
|
Assigned task:
|
|
7
28
|
{assignedTask}
|
|
@@ -12,11 +33,13 @@ Latest user request:
|
|
|
12
33
|
Prior steps:
|
|
13
34
|
{priorSteps}
|
|
14
35
|
|
|
15
|
-
Use the assigned task as the primary instruction
|
|
16
|
-
Use the latest user request as supporting context
|
|
17
|
-
Use prior steps only
|
|
36
|
+
Use the assigned task as the primary instruction. The question will **not** be restated again here.
|
|
37
|
+
Use the latest user request as supporting context.
|
|
38
|
+
Use prior steps only to explain a previous result, failure, or likely next action.
|
|
39
|
+
|
|
40
|
+
---
|
|
18
41
|
|
|
19
|
-
|
|
42
|
+
## Map Context
|
|
20
43
|
|
|
21
44
|
{layerSummary}
|
|
22
45
|
|
|
@@ -24,15 +47,6 @@ Use prior steps only when needed to explain a previous result, failure, or likel
|
|
|
24
47
|
|
|
25
48
|
{agents}
|
|
26
49
|
|
|
27
|
-
### Rules
|
|
28
|
-
|
|
29
|
-
- "What layers are in this map?" → List the layer names
|
|
30
|
-
- "What fields are in this layer?" → Call the tool to list the field names for that layer
|
|
31
|
-
- "What can you do?" / "What can I ask?" → Suggest specific queries using EXACT layer and field names from the context above
|
|
32
|
-
- "Tell me about this map" → Summarize layers and capabilities
|
|
33
|
-
- "Create a chart of all wells ans their depth" → If a question is map related but not supported by available capabilities, say so. Add that support for this might be added in the future.
|
|
34
|
-
- Questions completely unrelated to maps/GIS → Politely explain you only help with the map |
|
|
35
|
-
|
|
36
50
|
### Response Guidelines
|
|
37
51
|
|
|
38
52
|
When suggesting what users can ask, be SPECIFIC using actual layer names:
|
|
@@ -46,12 +60,15 @@ For "what can I ask" responses, provide 3-5 specific example queries using field
|
|
|
46
60
|
For off-topic questions:
|
|
47
61
|
"I can only help with this map. Try asking me to filter [LayerName] by [FieldName], or zoom to a location."
|
|
48
62
|
|
|
49
|
-
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Format
|
|
50
66
|
|
|
51
67
|
- Keep responses concise
|
|
52
68
|
- Use bullet points for lists
|
|
53
69
|
- Use new lines (\\n) and appropriate formatting in your response
|
|
70
|
+
- Use actual layer and field names from the map context in any suggestions
|
|
54
71
|
`;
|
|
55
72
|
export {
|
|
56
|
-
|
|
73
|
+
n as default
|
|
57
74
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import { dispatchCustomEvent as e } from "@langchain/core/callbacks/dispatch/web";
|
|
3
|
+
const n = async (s, a) => {
|
|
4
|
+
await e("trace_message", s, a);
|
|
5
|
+
}, o = async (s, a) => {
|
|
6
|
+
await e("graph_ux_suggestion", s, a);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
o as a,
|
|
10
|
+
n as s
|
|
11
|
+
};
|
|
@@ -97,6 +97,20 @@ Do not reinterpret the request into a different form.
|
|
|
97
97
|
|
|
98
98
|
---
|
|
99
99
|
|
|
100
|
+
## Follow-up Reference Resolution
|
|
101
|
+
|
|
102
|
+
If the latest user request refers to prior results or prior context using a referential phrase such as "these", "those", "them", "that set", "the previous results", "this", "it", "that one", "this parcel", "this location", or "that feature", then the request depends on earlier context.
|
|
103
|
+
|
|
104
|
+
This also applies to equivalent referential wording in other languages.
|
|
105
|
+
|
|
106
|
+
Resolve the reference using the most recent relevant chat history or successful prior step.
|
|
107
|
+
|
|
108
|
+
In this case, the \`assignedTask\` should be standalone and should preserve the referenced prior constraints while adding only the new constraint or question from the latest user request.
|
|
109
|
+
|
|
110
|
+
Do not leave ambiguous references like "these", "those", "them", "this", or "it" in \`assignedTask\` when they can be resolved from context.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
100
114
|
## Assigned Task Guidelines (IMPORTANT)
|
|
101
115
|
|
|
102
116
|
- The \`assignedTask\` must match the user’s request exactly in meaning
|
|
@@ -106,6 +120,8 @@ Do not reinterpret the request into a different form.
|
|
|
106
120
|
|
|
107
121
|
- Keep the task short, specific, and directly executable
|
|
108
122
|
- Keep wording close to the user’s request with minimal transformation
|
|
123
|
+
- When resolving follow-up references, only replace the ambiguous reference with the resolved prior context; keep the rest of the user’s wording as close as possible.
|
|
124
|
+
|
|
109
125
|
- Use only information explicitly present in the user request or provided context
|
|
110
126
|
|
|
111
127
|
- The \`assignedTask\` may represent only part of the user’s request when multiple steps are necessary
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { NodeInterrupt as
|
|
2
|
+
import { NodeInterrupt as E, StateGraph as L, START as w, END as m } from "@langchain/langgraph/web";
|
|
3
3
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
4
4
|
import "@arcgis/core/portal/Portal.js";
|
|
5
|
-
import
|
|
5
|
+
import "@arcgis/core/request.js";
|
|
6
|
+
import "@arcgis/toolkit/string";
|
|
7
|
+
import { h as I } from "./generateLayerDescriptions.js";
|
|
6
8
|
import "@langchain/core/messages";
|
|
9
|
+
import { s as i } from "./index.js";
|
|
7
10
|
import "@langchain/openai";
|
|
11
|
+
import "@arcgis/core/config.js";
|
|
8
12
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
9
13
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
10
|
-
import "@arcgis/core/request.js";
|
|
11
14
|
import "@langchain/core/prompts";
|
|
12
|
-
import { f as
|
|
13
|
-
import { h as
|
|
14
|
-
import { ToolNode as
|
|
15
|
+
import { f as g, z as v, A as T, B as R, C as F, D as C, E as A, F as $, I as N, J as b, K as q, L as M, g as _, r as k, M as S } from "./adapter.js";
|
|
16
|
+
import { h as V } from "./toolCallResponse.js";
|
|
17
|
+
import { ToolNode as j } from "@langchain/langgraph/prebuilt";
|
|
15
18
|
const h = 0.7, z = 10, D = async (t, e) => {
|
|
16
19
|
try {
|
|
17
20
|
await i({ text: "Similarity search to find fields" }, e);
|
|
18
|
-
const r =
|
|
21
|
+
const r = g(e, "fieldSearch"), a = g(e, "layersAndFieldsRegistry"), o = g(e, "embeddingCache"), n = await r.searchFields({
|
|
19
22
|
text: t.agentExecutionContext.assignedTask,
|
|
20
23
|
layerIds: t.vectorSearchLayerIds,
|
|
21
24
|
minScore: h,
|
|
22
25
|
topResults: z,
|
|
23
26
|
embeddingCache: o
|
|
24
|
-
}), c = n.map(({ layerId: d, results:
|
|
25
|
-
const y =
|
|
27
|
+
}), c = n.map(({ layerId: d, results: p }) => {
|
|
28
|
+
const y = p.map((s) => ` - ${s.name} (${s.score.toFixed(2)})`).join(`
|
|
26
29
|
`);
|
|
27
30
|
return `${a.get(d)?.layerItem.name ?? d}:
|
|
28
31
|
${y}`;
|
|
@@ -46,10 +49,10 @@ ${c}` : l = `No vector search results found for score over ${h}.`, await i({ tex
|
|
|
46
49
|
{ text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
|
|
47
50
|
e
|
|
48
51
|
);
|
|
49
|
-
const r =
|
|
52
|
+
const r = g(e, "layerSearch"), a = g(e, "layersAndFieldsRegistry"), o = await r.searchLayers({
|
|
50
53
|
text: t.agentExecutionContext.assignedTask,
|
|
51
54
|
minScore: P
|
|
52
|
-
}), n = o.map((d) => d.id), c = o.map(({ id: d, score:
|
|
55
|
+
}), n = o.map((d) => d.id), c = o.map(({ id: d, score: p }) => `${a.get(d)?.layerItem.name ?? d} (${p.toFixed(2)})`).join(`
|
|
53
56
|
`);
|
|
54
57
|
let l;
|
|
55
58
|
return n.length > 0 ? l = `Vector search completed. Matching layers with scores:
|
|
@@ -65,8 +68,8 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
65
68
|
}
|
|
66
69
|
}, f = [
|
|
67
70
|
v,
|
|
68
|
-
R,
|
|
69
71
|
T,
|
|
72
|
+
R,
|
|
70
73
|
F,
|
|
71
74
|
C,
|
|
72
75
|
A,
|
|
@@ -91,11 +94,12 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
91
94
|
}, o = await I({
|
|
92
95
|
promptText: r,
|
|
93
96
|
modelTier: "advanced",
|
|
97
|
+
config: e,
|
|
94
98
|
messages: x(t.agentExecutionContext.messages),
|
|
95
99
|
inputVariables: a,
|
|
96
100
|
tools: f
|
|
97
101
|
});
|
|
98
|
-
return await
|
|
102
|
+
return await V(o, e), {
|
|
99
103
|
...t,
|
|
100
104
|
agentExecutionContext: {
|
|
101
105
|
...t.agentExecutionContext,
|
|
@@ -104,7 +108,7 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
|
|
|
104
108
|
};
|
|
105
109
|
};
|
|
106
110
|
async function B(t, e) {
|
|
107
|
-
const a = await new
|
|
111
|
+
const a = await new j(f, { handleToolErrors: !1 }).invoke(
|
|
108
112
|
{
|
|
109
113
|
messages: x(t.agentExecutionContext.messages)
|
|
110
114
|
},
|
|
@@ -129,18 +133,18 @@ const U = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e),
|
|
|
129
133
|
s.description && `Description: ${s.description}`
|
|
130
134
|
].filter(Boolean).join(" | ") : y;
|
|
131
135
|
};
|
|
132
|
-
const { layerId: n, results: c } = a, l =
|
|
136
|
+
const { layerId: n, results: c } = a, l = g(e, "layersAndFieldsRegistry"), d = l.get(n)?.fieldRegistry;
|
|
133
137
|
if (!d)
|
|
134
138
|
continue;
|
|
135
|
-
let
|
|
136
|
-
|
|
139
|
+
let p = r.find((y) => y.layerId === n);
|
|
140
|
+
p || (p = {
|
|
137
141
|
layerId: n,
|
|
138
142
|
layerSummary: o(n),
|
|
139
143
|
fieldInfos: []
|
|
140
|
-
}, r.push(
|
|
144
|
+
}, r.push(p));
|
|
141
145
|
for (const y of c) {
|
|
142
146
|
const s = d.get(y.name);
|
|
143
|
-
s &&
|
|
147
|
+
s && p.fieldInfos.push(s);
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
return await i({ text: "Populated layerFieldInfo" }, e), { ...t, layerFieldInfo: r };
|
|
@@ -160,14 +164,14 @@ const U = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e),
|
|
|
160
164
|
message: "Choose a layer to apply the styles.",
|
|
161
165
|
metadata: [...r]
|
|
162
166
|
};
|
|
163
|
-
throw new
|
|
167
|
+
throw new E(n);
|
|
164
168
|
}
|
|
165
169
|
let o = null;
|
|
166
170
|
return Array.isArray(a.payload) && a.payload.length > 0 && (o = a.payload[0]), {
|
|
167
171
|
...t,
|
|
168
172
|
selectedLayerId: o ?? t.vectorSearchLayerIds[0]
|
|
169
173
|
};
|
|
170
|
-
}, O = (t, e) =>
|
|
174
|
+
}, O = (t, e) => k(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(t, e), Q = () => new L(S).addNode("requireLayerStylingServices", O).addNode("vectorSearchLayers", H).addNode("layerSelectionHITL", K).addNode("vectorSearchFields", D).addNode("populateLayerFieldInfo", J).addNode("agent", G).addNode("tools", B).addNode("earlyExit", U).addEdge(w, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
|
|
171
175
|
"layerSelectionHITL",
|
|
172
176
|
(e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
|
|
173
177
|
).addConditionalEdges(
|