@arcgis/ai-components 5.2.0-next.12 → 5.2.0-next.13
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/LLMAgent.js +1 -0
- package/dist/cdn/{EBISDZ5H.js → 4UDYY3HL.js} +1 -1
- package/dist/cdn/{ERL2CB2Y.js → 55R6J3FL.js} +5 -5
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/{34SG44C3.js → CE6VDP2D.js} +1 -1
- package/dist/cdn/{T43LEBBE.js → CFVVQXPJ.js} +18 -18
- package/dist/cdn/CI3QSFPS.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{Z2G7MP5L.js → DSVMXDPZ.js} +1 -1
- package/dist/cdn/{YLN2BZ5J.js → E2HENO3T.js} +1 -1
- package/dist/cdn/{JLKGS6Y5.js → ET453NAD.js} +1 -1
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/GPYYAQVI.js +2 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/K475UT3E.js +2 -0
- package/dist/cdn/KWTJAVWV.js +2 -0
- package/dist/cdn/{5CV7R5IS.js → LREQ3XAW.js} +1 -1
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/MRLTR3UO.js +16 -0
- package/dist/cdn/PB2ODJC7.js +2 -0
- package/dist/cdn/{QCSN44H4.js → QSA4T3BU.js} +1 -1
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/SBHLUL3Q.js +2 -0
- package/dist/cdn/{R56X6ZKR.js → SRSFESAD.js} +1 -1
- package/dist/cdn/SWBER53G.js +3 -0
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/XBW4MWQR.js +2 -0
- package/dist/cdn/Z7UWJ4AI.js +3 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +169 -168
- package/dist/chunks/arcgisKnowledgeGraph.js +3 -2
- package/dist/chunks/dataExplorationGraph.js +3 -2
- package/dist/chunks/generateLayerDescriptions.js +180 -178
- package/dist/chunks/helpGraph.js +3 -2
- package/dist/chunks/layerStylingGraph.js +1 -0
- package/dist/chunks/navigationGraph.js +3 -2
- package/dist/chunks/orchestrator.js +49 -48
- package/dist/chunks/toolCallResponse.js +10 -9
- package/dist/components/arcgis-assistant/customElement.js +54 -48
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +3 -2
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +4 -3
- 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/package.json +4 -4
- package/dist/cdn/24QNMEFG.js +0 -2
- package/dist/cdn/3NBDVZ2I.js +0 -2
- package/dist/cdn/53NTYC4I.js +0 -2
- package/dist/cdn/AZGGTNA3.js +0 -2
- package/dist/cdn/B7WJFBOZ.js +0 -2
- package/dist/cdn/DZ2QWNUA.js +0 -3
- package/dist/cdn/F6QHMKF5.js +0 -2
- package/dist/cdn/H2CHHGGH.js +0 -2
- package/dist/cdn/HWKDNS4K.js +0 -4
- package/dist/cdn/IMQ4TVHF.js +0 -16
- package/dist/cdn/IRZDTYO2.js +0 -2
- package/dist/cdn/KHXUWZHB.js +0 -2
- package/dist/cdn/LIFK3QSD.js +0 -2
- package/dist/cdn/O3EN27N5.js +0 -2
- package/dist/cdn/PBO6FZN6.js +0 -2
- package/dist/cdn/Q3ZW4FYA.js +0 -3
- package/dist/cdn/UPEEHMSY.js +0 -2
- package/dist/cdn/WAIFKDR3.js +0 -2
- package/dist/cdn/XON27U6U.js +0 -2
- package/dist/cdn/YUKR4AZW.js +0 -2
|
@@ -3,6 +3,7 @@ import { StateGraph as f, START as x, END as h, Command as k } from "@langchain/
|
|
|
3
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 "@arcgis/toolkit/string";
|
|
6
7
|
import { h as G, e as N } from "./generateLayerDescriptions.js";
|
|
7
8
|
import { AIMessage as R } from "@langchain/core/messages";
|
|
8
9
|
import "@langchain/core/callbacks/dispatch/web";
|
|
@@ -199,7 +200,7 @@ _example: "Discover and add all the relationships originating at 'Entity E' to t
|
|
|
199
200
|
_example: "Show me all entities with a name similar to 'Smith' and add them to the link chart"_
|
|
200
201
|
_example: "Find reports in my graph that have a title similar to 'Quarterly Earnings'"_
|
|
201
202
|
_example: "Find John Smith and all people he has made phone calls to in the last year"_
|
|
202
|
-
_example: "What is the average age of all people who work for Esri?"_`,
|
|
203
|
+
_example: "What is the average age of all people who work for Esri?"_`, ie = {
|
|
203
204
|
id: "arcgisKnowledge",
|
|
204
205
|
name: "ArcgisKnowledge Agent",
|
|
205
206
|
description: P,
|
|
@@ -207,5 +208,5 @@ _example: "What is the average age of all people who work for Esri?"_`, re = {
|
|
|
207
208
|
workspace: m
|
|
208
209
|
};
|
|
209
210
|
export {
|
|
210
|
-
|
|
211
|
+
ie as A
|
|
211
212
|
};
|
|
@@ -3,6 +3,7 @@ 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 "@arcgis/toolkit/string";
|
|
6
7
|
import { h as _, e as Q } from "./generateLayerDescriptions.js";
|
|
7
8
|
import { AIMessage as j } from "@langchain/core/messages";
|
|
8
9
|
import { s as n } from "./index.js";
|
|
@@ -298,7 +299,7 @@ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text
|
|
|
298
299
|
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.
|
|
299
300
|
_Example: “How many features are there?”_
|
|
300
301
|
_Example: “What’s the average population?”_
|
|
301
|
-
_Example: “Which values are in the status field?”_`,
|
|
302
|
+
_Example: “Which values are in the status field?”_`, Ce = {
|
|
302
303
|
id: "dataExploration",
|
|
303
304
|
name: "Data Exploration Agent",
|
|
304
305
|
description: de,
|
|
@@ -306,5 +307,5 @@ ${r}` : i = "Vector search completed. No matching layers found.", await n({ text
|
|
|
306
307
|
workspace: b
|
|
307
308
|
};
|
|
308
309
|
export {
|
|
309
|
-
|
|
310
|
+
Ce as D
|
|
310
311
|
};
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { Annotation as
|
|
3
|
-
import
|
|
2
|
+
import { Annotation as m } from "@langchain/langgraph/web";
|
|
3
|
+
import u, { z as r } from "zod";
|
|
4
4
|
import { ChatPromptTemplate as D, SystemMessagePromptTemplate as K } from "@langchain/core/prompts";
|
|
5
5
|
import { s as f } from "./index.js";
|
|
6
6
|
import { AIMessage as B, isAIMessage as W, isToolMessage as X } from "@langchain/core/messages";
|
|
7
|
-
import { createAgent as
|
|
7
|
+
import { createAgent as G, summarizationMiddleware as H, modelCallLimitMiddleware as J } from "langchain";
|
|
8
8
|
import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
|
|
9
|
-
import
|
|
9
|
+
import q from "@arcgis/core/portal/Portal.js";
|
|
10
10
|
import Z from "@arcgis/core/identity/IdentityManager.js";
|
|
11
|
-
import ee from "@arcgis/
|
|
12
|
-
|
|
11
|
+
import { generateGuid as ee } from "@arcgis/toolkit/string";
|
|
12
|
+
import te from "@arcgis/core/config.js";
|
|
13
|
+
const F = {
|
|
13
14
|
advanced: "gpt-5.2",
|
|
14
15
|
default: "gpt-5-mini",
|
|
15
16
|
fast: "gpt-5.4-nano"
|
|
16
|
-
},
|
|
17
|
+
}, I = {
|
|
17
18
|
default: "text-embedding-ada-002"
|
|
18
|
-
},
|
|
19
|
-
let
|
|
20
|
-
const
|
|
21
|
-
const t =
|
|
19
|
+
}, T = /* @__PURE__ */ new Map();
|
|
20
|
+
let M = null;
|
|
21
|
+
const ne = () => {
|
|
22
|
+
const t = q.getDefault().helperServices;
|
|
22
23
|
if (!t?.aiModels?.url)
|
|
23
24
|
throw new Error("AI Models Service URL is not defined in the portal's helper services.");
|
|
24
25
|
return t.aiModels.url;
|
|
25
26
|
}, U = async (e) => {
|
|
26
|
-
const t =
|
|
27
|
-
|
|
27
|
+
const t = ne();
|
|
28
|
+
T.size === 0 && (M || (M = (async () => {
|
|
28
29
|
try {
|
|
29
30
|
const n = await fetch(`${t}/models`);
|
|
30
31
|
if (!n.ok)
|
|
31
32
|
throw new Error("Failed to fetch AI service discovery data.");
|
|
32
|
-
(await n.json()).models.forEach((
|
|
33
|
+
(await n.json()).models.forEach((i) => T.set(i.name, i));
|
|
33
34
|
} catch (n) {
|
|
34
|
-
throw
|
|
35
|
+
throw M = null, n;
|
|
35
36
|
}
|
|
36
|
-
})()), await
|
|
37
|
-
const s =
|
|
37
|
+
})()), await M);
|
|
38
|
+
const s = T.get(e);
|
|
38
39
|
if (!s)
|
|
39
40
|
throw new Error(`Model '${e}' is not available in the discovery service.`);
|
|
40
41
|
return s.endpoint;
|
|
41
|
-
},
|
|
42
|
+
}, se = async (e = "default") => await U(F[e]), oe = async (e = "default") => await U(I[e]), h = (e, t) => t, P = (e, t) => ({
|
|
42
43
|
...e,
|
|
43
44
|
...t
|
|
44
45
|
}), _ = (e = "", t) => {
|
|
@@ -50,10 +51,10 @@ const te = () => {
|
|
|
50
51
|
return s;
|
|
51
52
|
if (n === s)
|
|
52
53
|
return e;
|
|
53
|
-
const
|
|
54
|
+
const o = n.split(`
|
|
54
55
|
|
|
55
56
|
`);
|
|
56
|
-
return
|
|
57
|
+
return o[o.length - 1]?.trim() === s ? e : `${e}
|
|
57
58
|
|
|
58
59
|
${s}`;
|
|
59
60
|
}, j = () => ({
|
|
@@ -63,65 +64,65 @@ ${s}`;
|
|
|
63
64
|
priorSteps: [],
|
|
64
65
|
sharedState: {}
|
|
65
66
|
}), ie = () => ({
|
|
66
|
-
agentExecutionContext:
|
|
67
|
+
agentExecutionContext: m({
|
|
67
68
|
reducer: P,
|
|
68
69
|
default: j
|
|
69
70
|
}),
|
|
70
|
-
outputMessage:
|
|
71
|
+
outputMessage: m({
|
|
71
72
|
reducer: _,
|
|
72
73
|
default: () => ""
|
|
73
74
|
}),
|
|
74
|
-
summary:
|
|
75
|
+
summary: m({
|
|
75
76
|
reducer: h,
|
|
76
77
|
default: () => ""
|
|
77
78
|
}),
|
|
78
|
-
status:
|
|
79
|
+
status: m({
|
|
79
80
|
reducer: h
|
|
80
81
|
})
|
|
81
|
-
}),
|
|
82
|
+
}), Ne = () => ({
|
|
82
83
|
...ie(),
|
|
83
|
-
sharedStatePatch:
|
|
84
|
+
sharedStatePatch: m({
|
|
84
85
|
reducer: h
|
|
85
86
|
})
|
|
86
|
-
}),
|
|
87
|
-
agentExecutionContext:
|
|
87
|
+
}), Oe = m.Root({
|
|
88
|
+
agentExecutionContext: m({
|
|
88
89
|
default: j,
|
|
89
90
|
reducer: P
|
|
90
91
|
}),
|
|
91
|
-
currentIntent:
|
|
92
|
+
currentIntent: m({
|
|
92
93
|
default: () => "none",
|
|
93
94
|
reducer: h
|
|
94
95
|
}),
|
|
95
|
-
lastExecutedAgent:
|
|
96
|
+
lastExecutedAgent: m({
|
|
96
97
|
default: () => "",
|
|
97
98
|
reducer: h
|
|
98
99
|
}),
|
|
99
|
-
requiresFollowUp:
|
|
100
|
+
requiresFollowUp: m({
|
|
100
101
|
default: () => !0,
|
|
101
102
|
reducer: h
|
|
102
103
|
}),
|
|
103
|
-
stepCount:
|
|
104
|
+
stepCount: m({
|
|
104
105
|
default: () => 0,
|
|
105
106
|
reducer: (e, t) => t ?? e + 1
|
|
106
107
|
}),
|
|
107
|
-
finalOutputMessage:
|
|
108
|
+
finalOutputMessage: m({
|
|
108
109
|
default: () => "",
|
|
109
110
|
reducer: _
|
|
110
111
|
})
|
|
111
|
-
}),
|
|
112
|
+
}), re = (e) => {
|
|
112
113
|
if (!e || typeof e != "object" || !("services" in e))
|
|
113
114
|
return !1;
|
|
114
115
|
const t = e.services;
|
|
115
116
|
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
116
|
-
},
|
|
117
|
+
}, ae = (e) => {
|
|
117
118
|
const t = e?.configurable;
|
|
118
|
-
return
|
|
119
|
-
},
|
|
119
|
+
return re(t) ? t : void 0;
|
|
120
|
+
}, ce = (e, t, s) => {
|
|
120
121
|
const n = e[t];
|
|
121
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((
|
|
122
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
122
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((o, i) => {
|
|
123
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
|
|
123
124
|
});
|
|
124
|
-
},
|
|
125
|
+
}, k = async (e) => (await ce(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt.js"), "./intent_prompt.md": () => import("./intent_prompt.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt.js") }), `./${e}.md`, 2)).default, le = async (e) => {
|
|
125
126
|
const { agent: t, messages: s, config: n } = e;
|
|
126
127
|
return { structuredResponse: (await t.invoke(
|
|
127
128
|
{
|
|
@@ -129,64 +130,65 @@ ${s}`;
|
|
|
129
130
|
},
|
|
130
131
|
n
|
|
131
132
|
)).structuredResponse };
|
|
132
|
-
},
|
|
133
|
+
}, de = (e) => typeof e == "string" && e.length > 0 ? e : void 0, pe = (e) => e && typeof e == "object" && "aborted" in e ? e : void 0, me = () => ee(), ue = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ge = (e) => {
|
|
133
134
|
const t = e?.configurable;
|
|
134
135
|
return {
|
|
135
|
-
conversationId:
|
|
136
|
-
abortSignal:
|
|
137
|
-
requestId:
|
|
136
|
+
conversationId: de(t?.thread_id),
|
|
137
|
+
abortSignal: pe(t?.abortSignal),
|
|
138
|
+
requestId: me(),
|
|
139
|
+
requestSource: ue(te.applicationName)
|
|
138
140
|
};
|
|
139
|
-
},
|
|
140
|
-
const t =
|
|
141
|
-
return async (
|
|
142
|
-
const { conversationId: a, abortSignal:
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
return await fetch(
|
|
146
|
-
...
|
|
147
|
-
headers:
|
|
148
|
-
signal:
|
|
141
|
+
}, $ = async ({ config: e }) => {
|
|
142
|
+
const t = q.getDefault(), n = (await Z.getCredential(`${t.url}/sharing`))?.token;
|
|
143
|
+
return async (o, i) => {
|
|
144
|
+
const { conversationId: a, abortSignal: l, requestId: c, requestSource: p } = ge(e), d = new Headers(i?.headers);
|
|
145
|
+
d.delete("Authorization"), d.delete("api-key"), n && n.length > 0 && (d.set("X-Esri-Authorization", `Bearer ${n}`), d.set("X-Esri-Request-Source", p)), a && a.length > 0 && d.set("X-Esri-Conversation-Id", a), c.length > 0 && d.set("X-Esri-Request-Id", c);
|
|
146
|
+
const y = l && i?.signal ? AbortSignal.any([l, i.signal]) : i?.signal ?? l;
|
|
147
|
+
return await fetch(o, {
|
|
148
|
+
...i,
|
|
149
|
+
headers: d,
|
|
150
|
+
signal: y
|
|
149
151
|
});
|
|
150
152
|
};
|
|
151
|
-
},
|
|
152
|
-
const { modelTier: t = "default", temperature: s = 0, config: n } = e,
|
|
153
|
+
}, v = async (e = {}) => {
|
|
154
|
+
const { modelTier: t = "default", temperature: s = 0, config: n } = e, o = F[t], i = await se(t);
|
|
153
155
|
return new Q({
|
|
154
|
-
modelName:
|
|
156
|
+
modelName: o,
|
|
155
157
|
apiKey: "dummy-key",
|
|
156
158
|
// 5-mini does not support temperature parameter
|
|
157
159
|
...t !== "default" && { temperature: s },
|
|
158
160
|
configuration: {
|
|
159
|
-
baseURL:
|
|
160
|
-
fetch: await
|
|
161
|
+
baseURL: i,
|
|
162
|
+
fetch: await $({ config: n })
|
|
161
163
|
}
|
|
162
164
|
});
|
|
163
|
-
},
|
|
164
|
-
const { tier: t = "default", config: s } = e, n =
|
|
165
|
+
}, Ve = async (e = {}) => {
|
|
166
|
+
const { tier: t = "default", config: s } = e, n = I[t], o = await oe(t);
|
|
165
167
|
return new Y({
|
|
166
168
|
modelName: n,
|
|
167
169
|
apiKey: "dummy-key",
|
|
168
170
|
configuration: {
|
|
169
|
-
baseURL:
|
|
170
|
-
fetch: await
|
|
171
|
+
baseURL: o,
|
|
172
|
+
fetch: await $({ config: s })
|
|
171
173
|
},
|
|
172
174
|
batchSize: 2048,
|
|
173
175
|
maxConcurrency: 10
|
|
174
176
|
});
|
|
175
|
-
},
|
|
177
|
+
}, fe = r.object({
|
|
176
178
|
id: r.string().min(1),
|
|
177
179
|
name: r.string().min(1),
|
|
178
180
|
description: r.string().min(1)
|
|
179
181
|
});
|
|
180
|
-
r.array(
|
|
181
|
-
const
|
|
182
|
+
r.array(fe);
|
|
183
|
+
const R = (e) => JSON.stringify(e, null, 2), he = (e) => {
|
|
182
184
|
const t = e.map((n) => n.id), s = r.enum(t);
|
|
183
185
|
return r.object({
|
|
184
186
|
intent: s.nullable(),
|
|
185
187
|
assignedTask: r.string().nullable(),
|
|
186
188
|
requiresFollowUp: r.boolean()
|
|
187
189
|
});
|
|
188
|
-
},
|
|
189
|
-
const s =
|
|
190
|
+
}, ze = async (e, t) => {
|
|
191
|
+
const s = ae(t);
|
|
190
192
|
if (s.abortSignal?.aborted)
|
|
191
193
|
return await f({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
192
194
|
...e,
|
|
@@ -196,35 +198,35 @@ const C = (e) => JSON.stringify(e, null, 2), ue = (e) => {
|
|
|
196
198
|
};
|
|
197
199
|
try {
|
|
198
200
|
await f({ text: "Asking LLM to route to an agent" }, t);
|
|
199
|
-
const
|
|
201
|
+
const o = s.services.agentRegistry?.list() ?? [], i = o.map(({ agent: g }) => ({
|
|
200
202
|
id: g.id,
|
|
201
203
|
name: g.name,
|
|
202
204
|
description: g.description
|
|
203
205
|
}));
|
|
204
|
-
if (!
|
|
206
|
+
if (!i.length)
|
|
205
207
|
return await f({ text: "No agents registered; skipping intent detection" }, t), {
|
|
206
208
|
...e,
|
|
207
209
|
currentIntent: "none",
|
|
208
210
|
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
209
211
|
};
|
|
210
|
-
const a = await
|
|
211
|
-
registeredAgents:
|
|
212
|
-
priorSteps:
|
|
212
|
+
const a = await k("intent_prompt"), l = R(i), c = he(i), p = {
|
|
213
|
+
registeredAgents: l,
|
|
214
|
+
priorSteps: R(e.agentExecutionContext.priorSteps),
|
|
213
215
|
userRequest: e.agentExecutionContext.userRequest
|
|
214
|
-
},
|
|
215
|
-
model: await
|
|
216
|
+
}, y = await D.fromTemplate(a).format(p), E = G({
|
|
217
|
+
model: await v({
|
|
216
218
|
modelTier: "fast",
|
|
217
219
|
config: t
|
|
218
220
|
}),
|
|
219
221
|
tools: [],
|
|
220
|
-
systemPrompt:
|
|
222
|
+
systemPrompt: y,
|
|
221
223
|
responseFormat: c,
|
|
222
224
|
middleware: [
|
|
223
225
|
// Preserve recent conversation context while summarizing older messages
|
|
224
226
|
// to control token usage without losing important intent signals.
|
|
225
227
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
226
|
-
|
|
227
|
-
model: await
|
|
228
|
+
H({
|
|
229
|
+
model: await v({
|
|
228
230
|
modelTier: "fast",
|
|
229
231
|
config: t
|
|
230
232
|
}),
|
|
@@ -233,30 +235,30 @@ const C = (e) => JSON.stringify(e, null, 2), ue = (e) => {
|
|
|
233
235
|
}),
|
|
234
236
|
// Enforce no loop/retry.
|
|
235
237
|
// 1 usual LLM call and 1 optional summarization call.
|
|
236
|
-
|
|
238
|
+
J({ runLimit: 2 })
|
|
237
239
|
]
|
|
238
|
-
}), { structuredResponse: V } = await
|
|
240
|
+
}), { structuredResponse: V } = await le({
|
|
239
241
|
agent: E,
|
|
240
242
|
messages: e.agentExecutionContext.messages,
|
|
241
243
|
config: t
|
|
242
|
-
}),
|
|
244
|
+
}), w = c.parse(
|
|
243
245
|
V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
244
|
-
),
|
|
246
|
+
), x = w.intent ?? "none", z = {
|
|
245
247
|
...e,
|
|
246
|
-
currentIntent:
|
|
247
|
-
requiresFollowUp:
|
|
248
|
+
currentIntent: x,
|
|
249
|
+
requiresFollowUp: w.requiresFollowUp,
|
|
248
250
|
agentExecutionContext: {
|
|
249
251
|
...e.agentExecutionContext,
|
|
250
|
-
assignedTask:
|
|
252
|
+
assignedTask: w.assignedTask ?? ""
|
|
251
253
|
}
|
|
252
254
|
};
|
|
253
|
-
if (
|
|
254
|
-
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${
|
|
255
|
+
if (x === "none") {
|
|
256
|
+
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${o.map(({ agent: L }) => L.name).join(", ")}.
|
|
255
257
|
|
|
256
258
|
Please ask a question that can be answered by one of these agents.`;
|
|
257
259
|
return await f({ text: "LLM did not identify a clear intent." }, t), {
|
|
258
260
|
...e,
|
|
259
|
-
currentIntent:
|
|
261
|
+
currentIntent: x,
|
|
260
262
|
requiresFollowUp: !1,
|
|
261
263
|
finalOutputMessage: g,
|
|
262
264
|
agentExecutionContext: {
|
|
@@ -277,29 +279,29 @@ Please ask a question that can be answered by one of these agents.`;
|
|
|
277
279
|
}
|
|
278
280
|
return await f(
|
|
279
281
|
{
|
|
280
|
-
text: `Agent picked: ${
|
|
281
|
-
Task Assigned: ${
|
|
282
|
-
Requires Follow-Up: ${
|
|
282
|
+
text: `Agent picked: ${x}
|
|
283
|
+
Task Assigned: ${w.assignedTask ?? ""}
|
|
284
|
+
Requires Follow-Up: ${w.requiresFollowUp}`
|
|
283
285
|
},
|
|
284
286
|
t
|
|
285
287
|
), z;
|
|
286
288
|
} catch (n) {
|
|
287
289
|
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
288
290
|
}
|
|
289
|
-
},
|
|
291
|
+
}, ye = "0.1", b = 1536, we = "openai", be = I.default, ve = `Name: {name}
|
|
290
292
|
Title: {title}
|
|
291
|
-
Description: {description}`,
|
|
293
|
+
Description: {description}`, xe = `Name: {name}
|
|
292
294
|
Alias: {alias}
|
|
293
|
-
Description: {description}`,
|
|
294
|
-
schemaVersion: r.literal(
|
|
295
|
+
Description: {description}`, Le = r.object({
|
|
296
|
+
schemaVersion: r.literal(ye),
|
|
295
297
|
modified: r.number().int().nonnegative(),
|
|
296
298
|
embeddings: r.object({
|
|
297
|
-
modelProvider: r.literal(
|
|
298
|
-
model: r.literal(
|
|
299
|
-
dimensions: r.literal(
|
|
299
|
+
modelProvider: r.literal(we),
|
|
300
|
+
model: r.literal(be),
|
|
301
|
+
dimensions: r.literal(b),
|
|
300
302
|
templates: r.object({
|
|
301
|
-
layer: r.string().default(
|
|
302
|
-
field: r.string().default(
|
|
303
|
+
layer: r.string().default(ve),
|
|
304
|
+
field: r.string().default(xe)
|
|
303
305
|
})
|
|
304
306
|
}),
|
|
305
307
|
layers: r.array(
|
|
@@ -308,144 +310,144 @@ Description: {description}`, $e = r.object({
|
|
|
308
310
|
name: r.string().min(1),
|
|
309
311
|
title: r.string().catch(""),
|
|
310
312
|
description: r.string().catch(""),
|
|
311
|
-
vector: r.array(r.number()).length(
|
|
312
|
-
message: `Layer vector must be exactly ${
|
|
313
|
+
vector: r.array(r.number()).length(b, {
|
|
314
|
+
message: `Layer vector must be exactly ${b} dimensions`
|
|
313
315
|
}),
|
|
314
316
|
fields: r.array(
|
|
315
317
|
r.object({
|
|
316
318
|
name: r.string().min(1),
|
|
317
319
|
alias: r.string().catch(""),
|
|
318
320
|
description: r.string().catch(""),
|
|
319
|
-
vector: r.array(r.number()).length(
|
|
320
|
-
message: `Field vector must be exactly ${
|
|
321
|
+
vector: r.array(r.number()).length(b, {
|
|
322
|
+
message: `Field vector must be exactly ${b} dimensions`
|
|
321
323
|
})
|
|
322
324
|
})
|
|
323
325
|
)
|
|
324
326
|
})
|
|
325
327
|
).default([])
|
|
326
|
-
}),
|
|
328
|
+
}), Me = (e) => {
|
|
327
329
|
const t = /* @__PURE__ */ new Set();
|
|
328
330
|
for (const n of e)
|
|
329
331
|
if (W(n)) {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
332
|
+
const o = n;
|
|
333
|
+
o.tool_calls && o.tool_calls.length > 0 && o.tool_calls.forEach((i) => {
|
|
334
|
+
i.id && t.add(i.id);
|
|
333
335
|
});
|
|
334
336
|
}
|
|
335
337
|
return e.filter((n) => {
|
|
336
338
|
if (X(n)) {
|
|
337
|
-
const
|
|
338
|
-
return t.has(
|
|
339
|
+
const o = n;
|
|
340
|
+
return t.has(o.tool_call_id);
|
|
339
341
|
}
|
|
340
342
|
return !0;
|
|
341
343
|
});
|
|
342
344
|
}, A = (e, t) => {
|
|
343
345
|
const s = K.fromTemplate(e);
|
|
344
346
|
return D.fromMessages([s, ...t]);
|
|
345
|
-
},
|
|
346
|
-
const { promptText: t, modelTier: s, temperature: n, messages:
|
|
347
|
-
return a.pipe(
|
|
348
|
-
},
|
|
349
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
347
|
+
}, Te = async (e) => {
|
|
348
|
+
const { promptText: t, modelTier: s, temperature: n, messages: o, config: i } = e, a = A(t, o ?? []), l = await v({ modelTier: s, temperature: n, config: i });
|
|
349
|
+
return a.pipe(l);
|
|
350
|
+
}, Ke = async (e) => {
|
|
351
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: o, inputVariables: i, config: a } = e, c = await (await Te({
|
|
350
352
|
promptText: t,
|
|
351
353
|
modelTier: s,
|
|
352
354
|
temperature: n,
|
|
353
|
-
messages:
|
|
355
|
+
messages: o,
|
|
354
356
|
config: a
|
|
355
|
-
})).invoke(
|
|
357
|
+
})).invoke(i ?? {});
|
|
356
358
|
if (typeof c == "string")
|
|
357
359
|
return c;
|
|
358
|
-
const
|
|
359
|
-
return typeof
|
|
360
|
-
},
|
|
361
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
362
|
-
return await c.pipe(
|
|
363
|
-
},
|
|
364
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
365
|
-
return await
|
|
366
|
-
},
|
|
367
|
-
name:
|
|
368
|
-
description:
|
|
369
|
-
valueType:
|
|
370
|
-
alias:
|
|
371
|
-
}),
|
|
372
|
-
fields:
|
|
373
|
-
}), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "",
|
|
360
|
+
const p = c.content;
|
|
361
|
+
return typeof p == "string" ? p : JSON.stringify(p);
|
|
362
|
+
}, N = async (e) => {
|
|
363
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: o, inputVariables: i, schema: a, config: l } = e, c = A(t, o ?? []), d = (await v({ modelTier: s, temperature: n, config: l })).withStructuredOutput(a);
|
|
364
|
+
return await c.pipe(d).invoke(i ?? {});
|
|
365
|
+
}, Be = async (e) => {
|
|
366
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: o, inputVariables: i, tools: a, config: l } = e, c = a.length > 0 ? Me(o ?? []) : o ?? [], p = A(t, c), d = await v({ modelTier: s, temperature: n, config: l });
|
|
367
|
+
return await p.pipe(d.bindTools(a)).invoke(i ?? {});
|
|
368
|
+
}, Se = u.object({
|
|
369
|
+
name: u.string(),
|
|
370
|
+
description: u.string(),
|
|
371
|
+
valueType: u.string(),
|
|
372
|
+
alias: u.string()
|
|
373
|
+
}), Ie = u.object({
|
|
374
|
+
fields: u.array(Se)
|
|
375
|
+
}), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "", ke = (e, t) => {
|
|
374
376
|
const s = O(e, t.name);
|
|
375
377
|
return !!(s && s !== (t.alias ?? ""));
|
|
376
378
|
};
|
|
377
|
-
function
|
|
379
|
+
function C(e, t) {
|
|
378
380
|
const s = /* @__PURE__ */ new Map();
|
|
379
381
|
for (const n of e.fields) {
|
|
380
|
-
const
|
|
382
|
+
const o = t.fields.find((c) => c.name === n.name), i = S(e, n), a = ke(e, n), l = {
|
|
381
383
|
name: n.name,
|
|
382
384
|
type: n.type,
|
|
383
|
-
alias: a ?
|
|
384
|
-
description:
|
|
385
|
-
valueType:
|
|
385
|
+
alias: a ? i : o?.alias ?? i,
|
|
386
|
+
description: o?.description ?? n.description ?? "",
|
|
387
|
+
valueType: o?.valueType ?? n.valueType ?? "",
|
|
386
388
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
387
389
|
};
|
|
388
|
-
s.set(n.name,
|
|
390
|
+
s.set(n.name, l);
|
|
389
391
|
}
|
|
390
392
|
return s;
|
|
391
393
|
}
|
|
392
|
-
const
|
|
393
|
-
const s = await
|
|
394
|
-
const { name:
|
|
395
|
-
return [`Name: ${
|
|
394
|
+
const We = async (e) => {
|
|
395
|
+
const s = await k("field_descriptions_prompt"), n = e.fields.filter((a) => !(S(e, a) && a.description)).map((a) => {
|
|
396
|
+
const { name: l, type: c, description: p } = a, d = S(e, a);
|
|
397
|
+
return [`Name: ${l}`, `Type: ${c}`, `Alias: ${d}`, `Description: ${p ?? "N/A"}`].join(", ");
|
|
396
398
|
}).join(`
|
|
397
399
|
`);
|
|
398
400
|
if (n.length === 0)
|
|
399
|
-
return
|
|
400
|
-
const
|
|
401
|
+
return C(e, { fields: [] });
|
|
402
|
+
const o = {
|
|
401
403
|
existingItemTitle: e.portalItem?.title,
|
|
402
404
|
existingItemDescription: e.portalItem?.description,
|
|
403
405
|
existingLayerTitle: e.title,
|
|
404
406
|
existingLayerDescription: e.portalItem?.description,
|
|
405
407
|
fieldInformation: n
|
|
406
|
-
},
|
|
408
|
+
}, i = await N({
|
|
407
409
|
promptText: s,
|
|
408
|
-
schema:
|
|
409
|
-
inputVariables:
|
|
410
|
+
schema: Ie,
|
|
411
|
+
inputVariables: o
|
|
410
412
|
});
|
|
411
|
-
return
|
|
412
|
-
},
|
|
413
|
-
title:
|
|
414
|
-
description:
|
|
415
|
-
name:
|
|
416
|
-
}),
|
|
417
|
-
const n = await
|
|
418
|
-
fieldInformation: JSON.stringify(
|
|
413
|
+
return C(e, i);
|
|
414
|
+
}, Ae = u.object({
|
|
415
|
+
title: u.string(),
|
|
416
|
+
description: u.string(),
|
|
417
|
+
name: u.string().nullable()
|
|
418
|
+
}), Xe = async (e, t) => {
|
|
419
|
+
const n = await k("layer_descriptions_prompt"), o = Array.from(t.values()), i = {
|
|
420
|
+
fieldInformation: JSON.stringify(o, null, 2),
|
|
419
421
|
existingLayerTitle: e.title,
|
|
420
422
|
existingLayerDescription: e.portalItem?.description,
|
|
421
423
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
422
424
|
layerGeometryType: e.geometryType
|
|
423
425
|
};
|
|
424
|
-
return { ...await
|
|
426
|
+
return { ...await N({
|
|
425
427
|
promptText: n,
|
|
426
|
-
schema:
|
|
427
|
-
inputVariables:
|
|
428
|
+
schema: Ae,
|
|
429
|
+
inputVariables: i
|
|
428
430
|
}), name: e.title ?? null };
|
|
429
431
|
};
|
|
430
432
|
export {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
433
|
+
Oe as D,
|
|
434
|
+
Le as W,
|
|
435
|
+
Xe as a,
|
|
436
|
+
we as b,
|
|
437
|
+
v as c,
|
|
438
|
+
b as d,
|
|
439
|
+
Ke as e,
|
|
440
|
+
xe as f,
|
|
441
|
+
We as g,
|
|
442
|
+
Be as h,
|
|
443
|
+
N as i,
|
|
442
444
|
ie as j,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
445
|
+
Ne as k,
|
|
446
|
+
ve as l,
|
|
447
|
+
be as m,
|
|
448
|
+
oe as n,
|
|
449
|
+
ae as o,
|
|
450
|
+
ze as p,
|
|
451
|
+
Ve as q,
|
|
452
|
+
ye as s
|
|
451
453
|
};
|