@arcgis/ai-components 5.2.0-next.24 → 5.2.0-next.26
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/3AXQTBIA.js +134 -0
- package/dist/cdn/{2EMRDLJG.js → 3BSEFPAR.js} +1 -1
- package/dist/cdn/{FWXRFMNO.js → 3W6Z6X3K.js} +1 -1
- package/dist/cdn/{CMTXZ33N.js → 4NAXFKT2.js} +1 -1
- package/dist/cdn/{B4GH4POB.js → CXJ3SV3G.js} +1 -1
- package/dist/cdn/{BGVIBF6M.js → E4VBUHCE.js} +1 -1
- package/dist/cdn/{QPHLBARY.js → EWMKCXMH.js} +1 -1
- package/dist/cdn/{YIJSPLIP.js → G3HEXUCY.js} +1 -1
- package/dist/cdn/{GJUD7EA3.js → IGZWQJW7.js} +1 -1
- package/dist/cdn/LEPJUN3X.js +22 -0
- package/dist/cdn/{SASFHTVY.js → O3CDY64C.js} +5 -5
- package/dist/cdn/{2F2U6T5S.js → RR4LCFRE.js} +1 -1
- package/dist/cdn/VZMWVTXW.js +180 -0
- package/dist/cdn/W2IHPJ54.js +34 -0
- package/dist/cdn/{OARG3JNP.js → XVU5R3Z7.js} +1 -1
- package/dist/cdn/{GH263QNS.js → ZIXEFGIT.js} +1 -1
- package/dist/cdn/ZMSJQB65.js +99 -0
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1210 -1092
- package/dist/chunks/arcgisKnowledgeGraph.js +91 -74
- 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/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/5QAHYX7Y.js +0 -5
- package/dist/cdn/AMXYAMAZ.js +0 -161
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/KMQ3SP4I.js +0 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { StateGraph as
|
|
3
|
-
import { a as
|
|
2
|
+
import { StateGraph as x, START as k, END as c, Command as b } from "@langchain/langgraph/web";
|
|
3
|
+
import { a as K, c as _, b as T, d as A, e as S, s as M, q as v, g as u, h as q, t as g, r as C, i as E, G, j as m } from "./adapter.js";
|
|
4
4
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
5
5
|
import "@arcgis/core/portal/Portal.js";
|
|
6
6
|
import "@arcgis/toolkit/string";
|
|
7
|
-
import { h as
|
|
8
|
-
import { AIMessage as
|
|
7
|
+
import { h as N, e as R } from "./generateLayerDescriptions.js";
|
|
8
|
+
import { AIMessage as y } from "@langchain/core/messages";
|
|
9
9
|
import "@langchain/core/callbacks/dispatch/web";
|
|
10
10
|
import "@langchain/openai";
|
|
11
11
|
import "@arcgis/core/config.js";
|
|
@@ -13,43 +13,44 @@ import "@arcgis/core/core/reactiveUtils.js";
|
|
|
13
13
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
14
14
|
import "@arcgis/core/request.js";
|
|
15
15
|
import { ToolNode as L } from "@langchain/langgraph/prebuilt";
|
|
16
|
-
import { s as p, a as
|
|
16
|
+
import { s as p, a as z } from "./index.js";
|
|
17
17
|
import "@langchain/core/prompts";
|
|
18
18
|
const w = [
|
|
19
|
-
b,
|
|
20
|
-
_,
|
|
21
19
|
K,
|
|
22
|
-
|
|
20
|
+
_,
|
|
23
21
|
T,
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
A,
|
|
23
|
+
S,
|
|
24
|
+
M,
|
|
25
|
+
v
|
|
26
26
|
];
|
|
27
|
-
async function
|
|
28
|
-
const
|
|
27
|
+
async function D(e, t) {
|
|
28
|
+
const o = await u("arcgis_knowledge_tool_prompt"), s = q(t), n = {
|
|
29
29
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
30
30
|
userRequest: e.agentExecutionContext.userRequest,
|
|
31
31
|
priorSteps: e.agentExecutionContext.priorSteps,
|
|
32
|
-
contextType:
|
|
33
|
-
},
|
|
34
|
-
promptText:
|
|
32
|
+
contextType: s
|
|
33
|
+
}, r = await N({
|
|
34
|
+
promptText: o,
|
|
35
35
|
messages: e.arcgisKnowledgeMessages,
|
|
36
36
|
inputVariables: n,
|
|
37
|
-
tools: w
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
tools: w,
|
|
38
|
+
config: t
|
|
39
|
+
}), l = (r.tool_calls?.length ?? 0) > 0, a = typeof r.text == "string" ? r.text.trim() : "", i = a.length > 0, d = r.content.toString();
|
|
40
|
+
return !l && (s === "map" || s === "knowledgeGraph") ? {
|
|
40
41
|
...e,
|
|
41
|
-
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages,
|
|
42
|
-
outputMessage:
|
|
42
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, r],
|
|
43
|
+
outputMessage: s === "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.",
|
|
43
44
|
status: "success"
|
|
44
45
|
} : {
|
|
45
46
|
...e,
|
|
46
|
-
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages,
|
|
47
|
-
outputMessage: l ? d :
|
|
48
|
-
status: l ? e.status :
|
|
49
|
-
summary: d ?
|
|
47
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, r],
|
|
48
|
+
outputMessage: l ? d : a,
|
|
49
|
+
status: l ? e.status : i ? "success" : "failed",
|
|
50
|
+
summary: d ? g(d) : "ArcGIS Knowledge Agent tool executed."
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
+
const f = {
|
|
53
54
|
generateCypher: "generated-cypher-query",
|
|
54
55
|
queryGraphData: "graph-query-result",
|
|
55
56
|
searchGraphData: "graph-search-result",
|
|
@@ -59,110 +60,126 @@ const y = {
|
|
|
59
60
|
createLinkChart: "created-link-chart"
|
|
60
61
|
};
|
|
61
62
|
function F(e) {
|
|
62
|
-
return !!e && e.status === "success" && !!
|
|
63
|
+
return !!e && e.status === "success" && !!f[e.toolName];
|
|
63
64
|
}
|
|
64
65
|
function $(e) {
|
|
65
66
|
return {
|
|
66
|
-
type:
|
|
67
|
+
type: f[e.toolName],
|
|
67
68
|
data: e.details
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
async function I(e,
|
|
71
|
-
const
|
|
71
|
+
async function I(e, t) {
|
|
72
|
+
const o = new L(w, { handleToolErrors: !1 });
|
|
72
73
|
try {
|
|
73
|
-
const
|
|
74
|
+
const s = await o.invoke(
|
|
74
75
|
{
|
|
75
76
|
messages: e.arcgisKnowledgeMessages
|
|
76
77
|
},
|
|
77
|
-
|
|
78
|
+
t
|
|
78
79
|
), n = [];
|
|
79
|
-
for (const
|
|
80
|
-
let
|
|
81
|
-
if (typeof
|
|
82
|
-
throw new Error(`Unexpected tool message content type: ${typeof
|
|
80
|
+
for (const a of s.messages) {
|
|
81
|
+
let i;
|
|
82
|
+
if (typeof a.content != "string")
|
|
83
|
+
throw new Error(`Unexpected tool message content type: ${typeof a.content}. Expected string.`);
|
|
83
84
|
try {
|
|
84
|
-
|
|
85
|
+
i = JSON.parse(a.content);
|
|
85
86
|
} catch {
|
|
86
87
|
throw new Error(
|
|
87
|
-
`Failed to parse tool message content as JSON. Tool: ${
|
|
88
|
+
`Failed to parse tool message content as JSON. Tool: ${a.name ?? "unknown"}.
|
|
88
89
|
|
|
89
|
-
Original Content: ${
|
|
90
|
+
Original Content: ${a.content}`
|
|
90
91
|
);
|
|
91
92
|
}
|
|
92
|
-
if (!
|
|
93
|
+
if (!i || typeof i != "object" || !("toolName" in i))
|
|
93
94
|
throw new Error(
|
|
94
|
-
`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(
|
|
95
|
+
`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(i)}`
|
|
95
96
|
);
|
|
96
|
-
n.push(
|
|
97
|
+
n.push(i);
|
|
97
98
|
}
|
|
98
99
|
await p(
|
|
99
100
|
{
|
|
100
|
-
text: `Finished executing ArcGIS Knowledge Agent tools: ${
|
|
101
|
+
text: `Finished executing ArcGIS Knowledge Agent tools: ${s.messages.filter((a) => a.name).map((a) => a.name).join(", ")}`
|
|
101
102
|
},
|
|
102
|
-
|
|
103
|
+
t
|
|
103
104
|
);
|
|
104
|
-
const
|
|
105
|
-
return l && F(l) && await
|
|
105
|
+
const r = n.filter((a) => typeof a != "string").map((a) => `- Called Tool: ${a.toolName}, Status: ${a.status}`), l = n[0];
|
|
106
|
+
return l && F(l) && await z($(l), t), {
|
|
106
107
|
...e,
|
|
107
|
-
outputMessage:
|
|
108
|
+
outputMessage: r.join(`
|
|
108
109
|
`),
|
|
109
|
-
summary:
|
|
110
|
+
summary: r.length ? g(r.join(`
|
|
110
111
|
`)) : "ArcGIS Knowledge Agent did not execute any tools or return any results.",
|
|
111
|
-
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, ...
|
|
112
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, ...s.messages],
|
|
112
113
|
arcgisKnowledgeToolResult: n
|
|
113
114
|
};
|
|
114
|
-
} catch (
|
|
115
|
-
const n =
|
|
115
|
+
} catch (s) {
|
|
116
|
+
const n = s instanceof Error ? s.message : String(s);
|
|
116
117
|
return await p(
|
|
117
118
|
{ text: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}` },
|
|
118
|
-
|
|
119
|
+
t
|
|
119
120
|
), {
|
|
120
121
|
...e,
|
|
121
122
|
outputMessage: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`,
|
|
122
123
|
status: "failed",
|
|
123
|
-
summary:
|
|
124
|
+
summary: g(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),
|
|
124
125
|
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages]
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
const V = (e,
|
|
129
|
+
const V = (e, t) => (
|
|
129
130
|
//agent services (ex: embeddingsWorker) would go in the array below, if required.
|
|
130
|
-
|
|
131
|
+
C([], "ArcgisKnowledge Agent")(e, t)
|
|
131
132
|
);
|
|
132
|
-
async function j(e,
|
|
133
|
-
const
|
|
133
|
+
async function j(e, t) {
|
|
134
|
+
const s = (e.arcgisKnowledgeToolResult ?? []).map((d) => ({
|
|
134
135
|
...d,
|
|
135
136
|
details: void 0
|
|
136
137
|
// Remove details to avoid overwhelming the LLM with too much info
|
|
137
|
-
})), { knowledgeGraph: n } = await
|
|
138
|
+
})), { knowledgeGraph: n } = await E(t), r = G.getDataModelTypesSummary(n.dataModel), l = {
|
|
138
139
|
assignedTask: e.agentExecutionContext.assignedTask,
|
|
139
140
|
userRequest: e.agentExecutionContext.userRequest,
|
|
140
|
-
toolResult:
|
|
141
|
-
dataModelSummary:
|
|
142
|
-
},
|
|
141
|
+
toolResult: s,
|
|
142
|
+
dataModelSummary: r
|
|
143
|
+
}, a = await R({
|
|
143
144
|
promptText: await u("arcgis_knowledge_summarize_result_prompt"),
|
|
144
145
|
modelTier: "default",
|
|
145
|
-
inputVariables: l
|
|
146
|
-
|
|
146
|
+
inputVariables: l,
|
|
147
|
+
config: t
|
|
148
|
+
}), i = typeof a == "string" ? a : a.content;
|
|
149
|
+
return {
|
|
150
|
+
...e,
|
|
151
|
+
outputMessage: i,
|
|
152
|
+
status: "success",
|
|
153
|
+
summary: g(i),
|
|
154
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new y(i)]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async function O(e) {
|
|
158
|
+
const t = e.arcgisKnowledgeToolResult?.[0], o = t?.status === "success" ? t.summary : "ArcGIS Knowledge Agent tool execution failed.";
|
|
147
159
|
return {
|
|
148
160
|
...e,
|
|
149
|
-
outputMessage:
|
|
161
|
+
outputMessage: o,
|
|
150
162
|
status: "success",
|
|
151
|
-
summary:
|
|
152
|
-
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new
|
|
163
|
+
summary: g(o),
|
|
164
|
+
arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new y(o)]
|
|
153
165
|
};
|
|
154
166
|
}
|
|
155
|
-
function
|
|
156
|
-
return async (
|
|
157
|
-
goto:
|
|
167
|
+
function h(e) {
|
|
168
|
+
return async (t, o) => o?.signal?.aborted ? (await p({ text: "Knowledge Agent execution cancelled" }, o), new b({
|
|
169
|
+
goto: c,
|
|
158
170
|
update: {
|
|
159
171
|
outputMessage: "Knowledge Agent execution cancelled",
|
|
160
172
|
summary: "Knowledge Agent execution cancelled",
|
|
161
173
|
status: "failed"
|
|
162
174
|
}
|
|
163
|
-
})) : await e(
|
|
175
|
+
})) : await e(t, o);
|
|
164
176
|
}
|
|
165
|
-
const
|
|
177
|
+
const P = () => new x(m).addNode("requireArcgisKnowledgeServices", V).addNode("agent", h(D)).addNode("tools", h(I)).addNode("summarizationLLM", h(j)).addNode("finalizeToolSummary", h(O)).addEdge(k, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (t) => (t.arcgisKnowledgeMessages[t.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : c).addConditionalEdges("tools", (t) => {
|
|
178
|
+
if (t.status === "failed")
|
|
179
|
+
return c;
|
|
180
|
+
const o = t.arcgisKnowledgeToolResult?.[0];
|
|
181
|
+
return o?.status === "success" && ["applyLayout", "changeNonspatialVisibility"].includes(o.toolName) ? "finalizeToolSummary" : "summarizationLLM";
|
|
182
|
+
}).addEdge("summarizationLLM", c).addEdge("finalizeToolSummary", c), J = 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).
|
|
166
183
|
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.
|
|
167
184
|
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,
|
|
168
185
|
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
|
|
@@ -200,13 +217,13 @@ _example: "Discover and add all the relationships originating at 'Entity E' to t
|
|
|
200
217
|
_example: "Show me all entities with a name similar to 'Smith' and add them to the link chart"_
|
|
201
218
|
_example: "Find reports in my graph that have a title similar to 'Quarterly Earnings'"_
|
|
202
219
|
_example: "Find John Smith and all people he has made phone calls to in the last year"_
|
|
203
|
-
_example: "What is the average age of all people who work for Esri?"_`,
|
|
220
|
+
_example: "What is the average age of all people who work for Esri?"_`, le = {
|
|
204
221
|
id: "arcgisKnowledge",
|
|
205
222
|
name: "ArcgisKnowledge Agent",
|
|
206
|
-
description:
|
|
207
|
-
createGraph:
|
|
223
|
+
description: J,
|
|
224
|
+
createGraph: P,
|
|
208
225
|
workspace: m
|
|
209
226
|
};
|
|
210
227
|
export {
|
|
211
|
-
|
|
228
|
+
le as A
|
|
212
229
|
};
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const e = `##
|
|
2
|
+
const e = `## Membership Bind Parameters
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
The current link chart contains a subset of entities and relationships from the database. Their membership is available to Cypher queries as lists of string identifiers through these bind parameters:
|
|
5
|
+
|
|
6
|
+
- $entityIds
|
|
7
|
+
- $relationshipIds
|
|
8
|
+
|
|
9
|
+
If, and ONLY if, the user is asking for data to be limited by the records already on 'the current link chart', 'my link chart', or similar, the generated Cypher should filter using these parameters.
|
|
10
|
+
|
|
11
|
+
### START EXAMPLES
|
|
12
|
+
|
|
13
|
+
User request: 'Add all records that are connected to people on this link chart to the link chart'
|
|
14
|
+
Context: 'Person' entity in data model.
|
|
15
|
+
Expected Result: MATCH (n:Person)-[r]->(m) WHERE id(n) IN $entityIds return r, m
|
|
16
|
+
|
|
17
|
+
User request: 'Add all the suppliers to the link chart'
|
|
18
|
+
Context: 'Supplier' entity in the data model.
|
|
19
|
+
Expected Result: MATCH (s:Supplier) RETURN s
|
|
20
|
+
|
|
21
|
+
### END EXAMPLES
|
|
5
22
|
`;
|
|
6
23
|
export {
|
|
7
24
|
e as default
|
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const e = `##
|
|
2
|
+
const e = `## Membership Bind Parameters
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
The current map contains a subset of entities and relationships from the database. Their membership is available to Cypher queries as lists of string identifiers through these bind parameters:
|
|
5
|
+
|
|
6
|
+
- $entityIds
|
|
7
|
+
- $relationshipIds
|
|
8
|
+
|
|
9
|
+
Included Types:
|
|
10
|
+
{nonDynamicTypes}
|
|
11
|
+
|
|
12
|
+
Filtering rules:
|
|
13
|
+
|
|
14
|
+
- Apply membership filtering only when BOTH are true:
|
|
15
|
+
- The user is asking for data to be limited by the records already on 'the current map', 'my map', 'the knowledge graph layer' or similar.
|
|
16
|
+
- The variable in the cypher query is a type in Included Types above.
|
|
17
|
+
- IMPORTANT: In all other cases, DO NOT apply membership filtering. DO NOT include membership filters for any type not listed in Included Types above.
|
|
18
|
+
|
|
19
|
+
### START EXAMPLES
|
|
20
|
+
|
|
21
|
+
User request: 'Add all records that are connected to people on this map to the map'
|
|
22
|
+
Context: 'Person' entity in data model and included in the bind parameter types above.
|
|
23
|
+
Expected Result: MATCH (n:Person)-[r]->(m) WHERE id(n) IN $entityIds return r, m
|
|
24
|
+
|
|
25
|
+
User request: 'Add all the suppliers to the map'
|
|
26
|
+
Context: 'Supplier' entity in the data model.
|
|
27
|
+
Expected Result: MATCH (s:Supplier) RETURN s
|
|
28
|
+
|
|
29
|
+
User request: 'Add all suppliers connected to plants on my map'
|
|
30
|
+
Context: 'Plant' entity in data model but not included in the bind parameter types above.
|
|
31
|
+
Expected Result: MATCH (p:Plant)-[r]->(s:Supplier) return r, s
|
|
32
|
+
|
|
33
|
+
### END EXAMPLES
|
|
5
34
|
`;
|
|
6
35
|
export {
|
|
7
36
|
e as default
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
const e = `# ArcGIS Knowledge Graph Cypher Rules
|
|
3
|
+
|
|
4
|
+
## GOAL
|
|
5
|
+
|
|
6
|
+
Generate a Cypher query that answers the user’s request and conforms to the data model.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. USER OVERRIDES (HIGHEST PRIORITY)
|
|
11
|
+
|
|
12
|
+
If the user specifies any of the following, ALWAYS follow their instructions over defaults:
|
|
13
|
+
|
|
14
|
+
- LIMIT (or no limit)
|
|
15
|
+
- Output columns / data model
|
|
16
|
+
- Inclusion/exclusion of globalid
|
|
17
|
+
- Ordering, grouping, filtering, projection
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. DATA MODEL CONFORMANCE (NON-NEGOTIABLE)
|
|
22
|
+
|
|
23
|
+
Use ONLY valid data model elements.
|
|
24
|
+
|
|
25
|
+
### Required
|
|
26
|
+
|
|
27
|
+
- Use only valid entity types, relationship types, and properties
|
|
28
|
+
- Ensure relationships connect valid entity types
|
|
29
|
+
- infer direction from user prompt. if not clear use the least restrictive valid form supported by the model.
|
|
30
|
+
|
|
31
|
+
### VALIDATION RULES (STRICT)
|
|
32
|
+
|
|
33
|
+
- Enforce exact schema match: all entities, relationships, and properties must exist exactly in the data model
|
|
34
|
+
- Validate relationship integrity: types, source→target pairing, and direction must match schema
|
|
35
|
+
- Enforce field correctness: properties and filters must exist on the referenced type and use valid data types
|
|
36
|
+
- Ensure alias consistency: each alias maps to one type only and cannot change meaning
|
|
37
|
+
- Apply strict failure: if any component is invalid, do NOT generate the query and do NOT infer or repair
|
|
38
|
+
|
|
39
|
+
## 4. PATH RESOLUTION
|
|
40
|
+
|
|
41
|
+
- First attempt a direct relationship
|
|
42
|
+
- If none exists → use a valid multi-hop path
|
|
43
|
+
- Each hop MUST be valid in the data model
|
|
44
|
+
- Max path length: 3 (unless user requests more)
|
|
45
|
+
|
|
46
|
+
### Path selection
|
|
47
|
+
|
|
48
|
+
- Prefer shortest valid path
|
|
49
|
+
- If multiple valid paths exist → choose best match to user intent
|
|
50
|
+
- If no valid path exists → do not speculate
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 5. PERFORMANCE
|
|
55
|
+
|
|
56
|
+
- Use the minimal number of entities and relationships
|
|
57
|
+
- Prefer shortest valid path
|
|
58
|
+
- Avoid unnecessary patterns or complexity
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 6. CYPHER RULES
|
|
63
|
+
|
|
64
|
+
- UNION queries must return identical columns
|
|
65
|
+
- Apply LIMIT only after UNION (not inside subqueries)
|
|
66
|
+
- Do NOT use: OVER, REDUCE()
|
|
67
|
+
- Do NOT use reserved keywords as variables (call, match, return, as etc.)
|
|
68
|
+
- Use only valid openCypher syntax
|
|
69
|
+
- After OPTIONAL MATCH, always add:
|
|
70
|
+
WITH ...
|
|
71
|
+
WHERE var IS NOT NULL
|
|
72
|
+
before using var in any MATCH or relationship pattern.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 7. SPATIAL RULES
|
|
77
|
+
|
|
78
|
+
- Prefer graph relationships over spatial functions
|
|
79
|
+
- Use spatial functions only when necessary
|
|
80
|
+
- Always ensure geometry is not null if using spatial functions
|
|
81
|
+
- for example: WHERE n.shape IS NOT NULL
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 9. DEFAULT OUTPUT (IF NOT SPECIFIED)
|
|
86
|
+
|
|
87
|
+
- Add LIMIT 50 unless results are clearly small
|
|
88
|
+
- Use descriptive aliases with AS
|
|
89
|
+
- ALWAYS Return full entities and relationships unless user requests specific properties
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 11. OUTPUT FORMAT
|
|
94
|
+
|
|
95
|
+
- Valid → return ONLY Cypher query
|
|
96
|
+
- No explanation
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
`;
|
|
100
|
+
export {
|
|
101
|
+
e as default
|
|
102
|
+
};
|
|
@@ -1,48 +1,137 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const
|
|
2
|
+
const n = `# ArcGIS Knowledge Agent — Action Summary
|
|
3
3
|
|
|
4
|
-
You are a
|
|
4
|
+
You are a Knowledge Graph assistant that has executed tool calls to answer a user request.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## Context
|
|
7
7
|
|
|
8
|
+
**Data model**
|
|
8
9
|
{dataModelSummary}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Assigned task:
|
|
11
|
+
**Assigned task**
|
|
13
12
|
{assignedTask}
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
**User request**
|
|
16
15
|
{userRequest}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
**Tool result**
|
|
20
18
|
{toolResult}
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Goal
|
|
23
|
+
|
|
24
|
+
Generate a concise, complete Markdown response using the tool results.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Priority Rules (Strict Order)
|
|
29
|
+
|
|
30
|
+
### 1. User Formatting Override (Highest Priority)
|
|
31
|
+
|
|
32
|
+
- If the user specifies a format (table, list, bullets, etc.):
|
|
33
|
+
- Use that format exactly
|
|
34
|
+
- Ignore ALL default formatting rules below
|
|
35
|
+
- Do NOT add summaries or extra sections unless requested
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### 2. Default Output (When no override)
|
|
40
|
+
|
|
41
|
+
Produce:
|
|
42
|
+
|
|
43
|
+
- **Summary**: 1–2 sentences (no header, no bullets)
|
|
44
|
+
- **Results**: Minimal, well-formatted data
|
|
45
|
+
- **Note (optional)**:
|
|
46
|
+
- 1–2 italicized sentences describing tool limitations
|
|
47
|
+
|
|
48
|
+
#### Limits
|
|
49
|
+
|
|
50
|
+
- maxPreviewItems: 5
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### 3. Output Constraints (Non-Negotiable)
|
|
55
|
+
|
|
56
|
+
- Output **valid Markdown only** (no JSON)
|
|
57
|
+
- Do NOT hallucinate data (entities, fields, counts, relationships)
|
|
58
|
+
- Do NOT include:
|
|
59
|
+
- reasoning
|
|
60
|
+
- classification labels
|
|
61
|
+
- follow-up questions
|
|
62
|
+
- next steps
|
|
63
|
+
- intro phrases (“Here are…”)
|
|
64
|
+
- restating the question
|
|
65
|
+
- End immediately after the response
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### 4. Data Handling Rules
|
|
70
|
+
|
|
71
|
+
- If results are empty → clearly state no results returned
|
|
72
|
+
- If insufficient data → state limitation, do NOT speculate
|
|
73
|
+
- Do NOT output:
|
|
74
|
+
- raw nested objects
|
|
75
|
+
- large arrays
|
|
76
|
+
- geometry
|
|
77
|
+
- Summarize complex structures
|
|
78
|
+
- Truncate long values with \`…\`
|
|
79
|
+
- Show entities/relationships only once
|
|
80
|
+
- Use:
|
|
81
|
+
- “entity” (not node)
|
|
82
|
+
- “relationship” (not edge)
|
|
83
|
+
- Hide \`globalid\` and \`objectid\` unless explicitly requested
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### 5. Formatting Rules (Default Mode Only)
|
|
88
|
+
|
|
89
|
+
- No headers; use _italic labels_ if needed
|
|
90
|
+
- Use:
|
|
91
|
+
- bullets → single item summaries
|
|
92
|
+
- tables → multiple results (limit to 5 rows)
|
|
93
|
+
- Reduce columns to key fields only
|
|
94
|
+
- Format:
|
|
95
|
+
- dates → “day month year”
|
|
96
|
+
- time separate from date
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### 6. Result-Type Formatting
|
|
101
|
+
|
|
102
|
+
**SEARCH_HITS**
|
|
103
|
+
|
|
104
|
+
- Highlight top match (bullets)
|
|
105
|
+
- Table for remaining results
|
|
106
|
+
|
|
107
|
+
**ENTITIES**
|
|
108
|
+
|
|
109
|
+
- Group by type (if multiple)
|
|
110
|
+
- Show key properties only
|
|
111
|
+
|
|
112
|
+
**RELATIONSHIPS**
|
|
113
|
+
|
|
114
|
+
- Format: \`(entity) —[relationship]→ (entity)\`
|
|
115
|
+
|
|
116
|
+
**PATHS**
|
|
117
|
+
|
|
118
|
+
- Summary + 1-3 examples
|
|
119
|
+
|
|
120
|
+
---
|
|
23
121
|
|
|
24
|
-
|
|
122
|
+
## Internal Processing (Do NOT output)
|
|
25
123
|
|
|
26
|
-
|
|
124
|
+
Classify results into:
|
|
27
125
|
|
|
28
|
-
|
|
126
|
+
- SEARCH_HITS, ENTITIES, RELATIONSHIPS, PATHS
|
|
29
127
|
|
|
30
|
-
|
|
31
|
-
- _Optional_ - Code block containing tool settings / query or search used etc for tool calls with multiple or complex settings
|
|
32
|
-
- _Optional_ - Markdown table of query or search results preview if these tools were used, and this is appropriate to answer the user's question. Ensure long property values are truncated to short lengths (20 chars) in the table if not directly relevant to the user's query. Do not re-order data in the table. If a query or search of graph data was done, this should be displayed.
|
|
33
|
-
- _Important_ If the summary or markdown table was generated based on data where only a limited preview of the full results of e.g. a search/query was available, indicate this at the end of the summary in a separate paragraph in italics, along the lines of 'NOTE: This summary was generated from a limited preview of the search / query results, and may not be accurate.'
|
|
128
|
+
## Failure Handling
|
|
34
129
|
|
|
35
|
-
|
|
130
|
+
- If data is insufficient → clearly state limitation
|
|
131
|
+
- Never infer or fabricate missing information
|
|
36
132
|
|
|
37
|
-
|
|
38
|
-
- Do NOT offer additional actions or suggestions.
|
|
39
|
-
- Do NOT explain what you can do next.
|
|
40
|
-
- End the response immediately after the summary.
|
|
41
|
-
- Do NOT include introductory phrases (e.g., "Found", "Here are", "The results show").
|
|
42
|
-
- Do NOT restate the assigned task or user’s question.
|
|
43
|
-
- Use Markdown formatting for the response, formatting in a way that makes the summary easy to read.
|
|
44
|
-
- When presenting tabular data, output a valid Markdown table.
|
|
133
|
+
---
|
|
45
134
|
`;
|
|
46
135
|
export {
|
|
47
|
-
|
|
136
|
+
n as default
|
|
48
137
|
};
|