@arcgis/ai-components 5.2.0-next.4 → 5.2.0-next.5
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 +22 -22
- package/dist/cdn/{S6W6HV4T.js → 3BKUCFKS.js} +1 -1
- package/dist/cdn/{YY2SBO3V.js → 3WINIQWY.js} +1 -1
- package/dist/cdn/{4HU7735A.js → CXWBEDXN.js} +1 -1
- package/dist/cdn/{GSEPHN3A.js → DO2P3PWF.js} +24 -24
- package/dist/cdn/{JY6LLOUJ.js → ERBQSEPQ.js} +1 -1
- package/dist/cdn/{V5YEZSRY.js → GBNUMN4J.js} +1 -1
- package/dist/cdn/{FHVXO2WG.js → GJUXVEOF.js} +4 -4
- package/dist/cdn/J5CMRCPS.js +3 -0
- package/dist/cdn/{MDVYQQUG.js → M6F4MXDK.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +6 -6
- package/dist/chunks/generateLayerDescriptions.js +223 -203
- package/dist/chunks/orchestrator.js +240 -201
- 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 +8 -3
- package/dist/utils/index.js +22 -18
- package/package.json +4 -4
- package/dist/cdn/ON2V5XI2.js +0 -3
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { Annotation as d } from "@langchain/langgraph/web";
|
|
3
|
-
import p, { z as
|
|
4
|
-
import { ChatPromptTemplate as
|
|
5
|
-
import { dispatchCustomEvent as
|
|
6
|
-
import { AIMessage as
|
|
7
|
-
import { createAgent as
|
|
8
|
-
import { ChatOpenAI as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
const
|
|
3
|
+
import p, { z as o } from "zod";
|
|
4
|
+
import { ChatPromptTemplate as F, SystemMessagePromptTemplate as B } from "@langchain/core/prompts";
|
|
5
|
+
import { dispatchCustomEvent as U } from "@langchain/core/callbacks/dispatch/web";
|
|
6
|
+
import { AIMessage as W, isAIMessage as H, isToolMessage as J } from "@langchain/core/messages";
|
|
7
|
+
import { createAgent as X, summarizationMiddleware as G, modelCallLimitMiddleware as Q } from "langchain";
|
|
8
|
+
import { ChatOpenAI as Y, OpenAIEmbeddings as Z } from "@langchain/openai";
|
|
9
|
+
import _ from "@arcgis/core/identity/IdentityManager.js";
|
|
10
|
+
import k from "@arcgis/core/portal/Portal.js";
|
|
11
|
+
const P = {
|
|
12
12
|
advanced: "gpt-5.2",
|
|
13
13
|
default: "gpt-5-mini",
|
|
14
14
|
fast: "gpt-5.4-nano"
|
|
15
|
-
},
|
|
15
|
+
}, A = {
|
|
16
16
|
default: "text-embedding-ada-002"
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
const t =
|
|
17
|
+
}, S = /* @__PURE__ */ new Map();
|
|
18
|
+
let v = null;
|
|
19
|
+
const ee = () => {
|
|
20
|
+
const t = k.getDefault().helperServices;
|
|
21
21
|
if (!t?.aiModels?.url)
|
|
22
22
|
throw new Error("AI Models Service URL is not defined in the portal's helper services.");
|
|
23
23
|
return t.aiModels.url;
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
|
|
24
|
+
}, q = async (e) => {
|
|
25
|
+
const t = ee();
|
|
26
|
+
S.size === 0 && (v || (v = (async () => {
|
|
27
27
|
try {
|
|
28
28
|
const n = await fetch(`${t}/models`);
|
|
29
29
|
if (!n.ok)
|
|
30
30
|
throw new Error("Failed to fetch AI service discovery data.");
|
|
31
|
-
(await n.json()).models.forEach((
|
|
31
|
+
(await n.json()).models.forEach((r) => S.set(r.name, r));
|
|
32
32
|
} catch (n) {
|
|
33
|
-
throw
|
|
33
|
+
throw v = null, n;
|
|
34
34
|
}
|
|
35
|
-
})()), await
|
|
36
|
-
const s =
|
|
35
|
+
})()), await v);
|
|
36
|
+
const s = S.get(e);
|
|
37
37
|
if (!s)
|
|
38
38
|
throw new Error(`Model '${e}' is not available in the discovery service.`);
|
|
39
39
|
return s.endpoint;
|
|
40
|
-
},
|
|
40
|
+
}, te = async (e = "default") => await q(P[e]), ne = async (e = "default") => await q(A[e]), f = (e, t) => t, j = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
}), $ = (e = "", t) => {
|
|
@@ -55,49 +55,49 @@ const Z = () => {
|
|
|
55
55
|
return i[i.length - 1]?.trim() === s ? e : `${e}
|
|
56
56
|
|
|
57
57
|
${s}`;
|
|
58
|
-
},
|
|
58
|
+
}, N = () => ({
|
|
59
59
|
userRequest: "",
|
|
60
60
|
assignedTask: "",
|
|
61
61
|
messages: [],
|
|
62
62
|
priorSteps: [],
|
|
63
63
|
sharedState: {}
|
|
64
|
-
}),
|
|
64
|
+
}), se = () => ({
|
|
65
65
|
agentExecutionContext: d({
|
|
66
|
-
reducer:
|
|
67
|
-
default:
|
|
66
|
+
reducer: j,
|
|
67
|
+
default: N
|
|
68
68
|
}),
|
|
69
69
|
outputMessage: d({
|
|
70
70
|
reducer: $,
|
|
71
71
|
default: () => ""
|
|
72
72
|
}),
|
|
73
73
|
summary: d({
|
|
74
|
-
reducer:
|
|
74
|
+
reducer: f,
|
|
75
75
|
default: () => ""
|
|
76
76
|
}),
|
|
77
77
|
status: d({
|
|
78
|
-
reducer:
|
|
78
|
+
reducer: f
|
|
79
79
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
80
|
+
}), Re = () => ({
|
|
81
|
+
...se(),
|
|
82
82
|
sharedStatePatch: d({
|
|
83
|
-
reducer:
|
|
83
|
+
reducer: f
|
|
84
84
|
})
|
|
85
|
-
}),
|
|
85
|
+
}), De = d.Root({
|
|
86
86
|
agentExecutionContext: d({
|
|
87
|
-
default:
|
|
88
|
-
reducer:
|
|
87
|
+
default: N,
|
|
88
|
+
reducer: j
|
|
89
89
|
}),
|
|
90
90
|
currentIntent: d({
|
|
91
91
|
default: () => "none",
|
|
92
|
-
reducer:
|
|
92
|
+
reducer: f
|
|
93
93
|
}),
|
|
94
94
|
lastExecutedAgent: d({
|
|
95
95
|
default: () => "",
|
|
96
|
-
reducer:
|
|
96
|
+
reducer: f
|
|
97
97
|
}),
|
|
98
98
|
requiresFollowUp: d({
|
|
99
99
|
default: () => !0,
|
|
100
|
-
reducer:
|
|
100
|
+
reducer: f
|
|
101
101
|
}),
|
|
102
102
|
stepCount: d({
|
|
103
103
|
default: () => 0,
|
|
@@ -107,16 +107,24 @@ ${s}`;
|
|
|
107
107
|
default: () => "",
|
|
108
108
|
reducer: $
|
|
109
109
|
})
|
|
110
|
-
}),
|
|
111
|
-
await
|
|
112
|
-
},
|
|
113
|
-
await
|
|
114
|
-
},
|
|
110
|
+
}), g = async (e, t) => {
|
|
111
|
+
await U("trace_message", e, t);
|
|
112
|
+
}, Fe = async (e, t) => {
|
|
113
|
+
await U("graph_ux_suggestion", e, t);
|
|
114
|
+
}, ie = (e) => {
|
|
115
|
+
if (!e || typeof e != "object" || !("services" in e))
|
|
116
|
+
return !1;
|
|
117
|
+
const t = e.services;
|
|
118
|
+
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
119
|
+
}, re = (e) => {
|
|
120
|
+
const t = e?.configurable;
|
|
121
|
+
return ie(t) ? t : void 0;
|
|
122
|
+
}, oe = (e, t, s) => {
|
|
115
123
|
const n = e[t];
|
|
116
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i,
|
|
117
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
124
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, r) => {
|
|
125
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(r.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
|
|
118
126
|
});
|
|
119
|
-
},
|
|
127
|
+
}, E = async (e) => (await oe(/* @__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, ae = async (e) => {
|
|
120
128
|
const { agent: t, messages: s, config: n } = e;
|
|
121
129
|
return { structuredResponse: (await t.invoke(
|
|
122
130
|
{
|
|
@@ -124,107 +132,117 @@ ${s}`;
|
|
|
124
132
|
},
|
|
125
133
|
n
|
|
126
134
|
)).structuredResponse };
|
|
127
|
-
},
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
}, O = (e, t) => async (s, n) => {
|
|
136
|
+
const i = new Headers(n?.headers);
|
|
137
|
+
i.delete("Authorization"), i.delete("api-key"), e && e.length > 0 && (i.set("X-Esri-Authorization", `Bearer ${e}`), i.set("X-Esri-Request-Source", "MapsSDK"));
|
|
138
|
+
const r = t && n?.signal ? AbortSignal.any([t, n.signal]) : n?.signal ?? t;
|
|
139
|
+
return await fetch(s, {
|
|
140
|
+
...n,
|
|
141
|
+
headers: i,
|
|
142
|
+
signal: r
|
|
132
143
|
});
|
|
133
|
-
},
|
|
134
|
-
const s =
|
|
135
|
-
return new
|
|
136
|
-
modelName:
|
|
144
|
+
}, b = async (e = {}) => {
|
|
145
|
+
const { modelTier: t = "default", temperature: s = 0, abortSignal: n } = e, i = k.getDefault(), r = await _.getCredential(`${i.url}/sharing`), a = P[t], c = await te(t);
|
|
146
|
+
return new Y({
|
|
147
|
+
modelName: a,
|
|
137
148
|
apiKey: "dummy-key",
|
|
138
149
|
// 5-mini does not support temperature parameter
|
|
139
|
-
...
|
|
150
|
+
...t !== "default" && { temperature: s },
|
|
140
151
|
configuration: {
|
|
141
|
-
baseURL:
|
|
142
|
-
fetch:
|
|
152
|
+
baseURL: c,
|
|
153
|
+
fetch: O(r.token, n)
|
|
143
154
|
}
|
|
144
155
|
});
|
|
145
|
-
},
|
|
146
|
-
const
|
|
147
|
-
return new
|
|
148
|
-
modelName:
|
|
156
|
+
}, Ue = async (e = "default", t) => {
|
|
157
|
+
const s = k.getDefault(), n = await _.getCredential(`${s.url}/sharing`), i = A[e], r = await ne(e);
|
|
158
|
+
return new Z({
|
|
159
|
+
modelName: i,
|
|
149
160
|
apiKey: "dummy-key",
|
|
150
161
|
configuration: {
|
|
151
|
-
baseURL:
|
|
152
|
-
fetch:
|
|
162
|
+
baseURL: r,
|
|
163
|
+
fetch: O(n.token, t)
|
|
153
164
|
},
|
|
154
165
|
batchSize: 2048,
|
|
155
166
|
maxConcurrency: 10
|
|
156
167
|
});
|
|
157
|
-
},
|
|
158
|
-
id:
|
|
159
|
-
name:
|
|
160
|
-
description:
|
|
168
|
+
}, ce = o.object({
|
|
169
|
+
id: o.string().min(1),
|
|
170
|
+
name: o.string().min(1),
|
|
171
|
+
description: o.string().min(1)
|
|
161
172
|
});
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
const t = e.map((n) => n.id), s =
|
|
165
|
-
return
|
|
173
|
+
o.array(ce);
|
|
174
|
+
const R = (e) => JSON.stringify(e, null, 2), le = (e) => {
|
|
175
|
+
const t = e.map((n) => n.id), s = o.enum(t);
|
|
176
|
+
return o.object({
|
|
166
177
|
intent: s.nullable(),
|
|
167
|
-
assignedTask:
|
|
168
|
-
requiresFollowUp:
|
|
178
|
+
assignedTask: o.string().nullable(),
|
|
179
|
+
requiresFollowUp: o.boolean()
|
|
169
180
|
});
|
|
170
|
-
},
|
|
181
|
+
}, _e = async (e, t) => {
|
|
182
|
+
const s = re(t);
|
|
183
|
+
if (s.abortSignal?.aborted)
|
|
184
|
+
return await g({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
185
|
+
...e,
|
|
186
|
+
currentIntent: "none",
|
|
187
|
+
requiresFollowUp: !1
|
|
188
|
+
};
|
|
171
189
|
try {
|
|
172
|
-
await
|
|
173
|
-
const
|
|
174
|
-
id:
|
|
175
|
-
name:
|
|
176
|
-
description:
|
|
190
|
+
await g({ text: "Asking LLM to route to an agent" }, t);
|
|
191
|
+
const r = (s.services.agentRegistry?.list() ?? []).map(({ agent: y }) => ({
|
|
192
|
+
id: y.id,
|
|
193
|
+
name: y.name,
|
|
194
|
+
description: y.description
|
|
177
195
|
}));
|
|
178
|
-
if (!
|
|
179
|
-
return await
|
|
180
|
-
const
|
|
181
|
-
registeredAgents:
|
|
182
|
-
priorSteps:
|
|
196
|
+
if (!r.length)
|
|
197
|
+
return await g({ text: "No agents registered; skipping intent detection" }, t), { ...e, currentIntent: "none" };
|
|
198
|
+
const a = await E("intent_prompt"), c = R(r), l = le(r), m = {
|
|
199
|
+
registeredAgents: c,
|
|
200
|
+
priorSteps: R(e.agentExecutionContext.priorSteps),
|
|
183
201
|
userRequest: e.agentExecutionContext.userRequest
|
|
184
|
-
},
|
|
185
|
-
model: await
|
|
202
|
+
}, T = await F.fromTemplate(a).format(m), C = X({
|
|
203
|
+
model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
|
|
186
204
|
tools: [],
|
|
187
|
-
systemPrompt:
|
|
205
|
+
systemPrompt: T,
|
|
188
206
|
checkpointer: !0,
|
|
189
|
-
responseFormat:
|
|
207
|
+
responseFormat: l,
|
|
190
208
|
middleware: [
|
|
191
209
|
// Preserve recent conversation context while summarizing older messages
|
|
192
210
|
// to control token usage without losing important intent signals.
|
|
193
211
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
194
|
-
|
|
195
|
-
model: await
|
|
212
|
+
G({
|
|
213
|
+
model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
|
|
196
214
|
trigger: { tokens: 4e3 },
|
|
197
215
|
keep: { messages: 6 }
|
|
198
216
|
}),
|
|
199
217
|
// Enforce no loop/retry.
|
|
200
218
|
// 1 usual LLM call and 1 optional summarization call.
|
|
201
|
-
|
|
219
|
+
Q({ runLimit: 2 })
|
|
202
220
|
]
|
|
203
|
-
}), { structuredResponse:
|
|
204
|
-
agent:
|
|
221
|
+
}), { structuredResponse: L } = await ae({
|
|
222
|
+
agent: C,
|
|
205
223
|
messages: e.agentExecutionContext.messages,
|
|
206
224
|
config: t
|
|
207
|
-
}),
|
|
208
|
-
|
|
209
|
-
),
|
|
225
|
+
}), h = l.parse(
|
|
226
|
+
L ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
227
|
+
), x = h.intent ?? "none", K = {
|
|
210
228
|
...e,
|
|
211
|
-
currentIntent:
|
|
212
|
-
requiresFollowUp:
|
|
229
|
+
currentIntent: x,
|
|
230
|
+
requiresFollowUp: h.requiresFollowUp,
|
|
213
231
|
agentExecutionContext: {
|
|
214
232
|
...e.agentExecutionContext,
|
|
215
|
-
assignedTask:
|
|
233
|
+
assignedTask: h.assignedTask ?? ""
|
|
216
234
|
}
|
|
217
235
|
};
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
220
|
-
return await
|
|
236
|
+
if (x === "none") {
|
|
237
|
+
const y = "I could not find a matching agent for that request. Please rephrase your question with more detail.";
|
|
238
|
+
return await g({ text: "LLM did not identify a clear intent." }, t), {
|
|
221
239
|
...e,
|
|
222
|
-
currentIntent:
|
|
240
|
+
currentIntent: x,
|
|
223
241
|
requiresFollowUp: !1,
|
|
224
242
|
agentExecutionContext: {
|
|
225
243
|
...e.agentExecutionContext,
|
|
226
244
|
assignedTask: "",
|
|
227
|
-
messages: [...e.agentExecutionContext.messages, new
|
|
245
|
+
messages: [...e.agentExecutionContext.messages, new W(y)],
|
|
228
246
|
priorSteps: [
|
|
229
247
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
230
248
|
{
|
|
@@ -237,111 +255,112 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
|
|
|
237
255
|
}
|
|
238
256
|
};
|
|
239
257
|
}
|
|
240
|
-
return await
|
|
258
|
+
return await g(
|
|
241
259
|
{
|
|
242
|
-
text: `Agent picked: ${
|
|
243
|
-
Task Assigned: ${
|
|
244
|
-
Requires Follow-Up: ${
|
|
260
|
+
text: `Agent picked: ${x}
|
|
261
|
+
Task Assigned: ${h.assignedTask ?? ""}
|
|
262
|
+
Requires Follow-Up: ${h.requiresFollowUp}`
|
|
245
263
|
},
|
|
246
264
|
t
|
|
247
|
-
),
|
|
248
|
-
} catch (
|
|
249
|
-
throw await
|
|
265
|
+
), K;
|
|
266
|
+
} catch (n) {
|
|
267
|
+
throw await g({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
250
268
|
}
|
|
251
|
-
},
|
|
269
|
+
}, de = "0.1", w = 1536, pe = "openai", me = A.default, ue = `Name: {name}
|
|
252
270
|
Title: {title}
|
|
253
|
-
Description: {description}`,
|
|
271
|
+
Description: {description}`, ge = `Name: {name}
|
|
254
272
|
Alias: {alias}
|
|
255
|
-
Description: {description}`,
|
|
256
|
-
schemaVersion:
|
|
257
|
-
modified:
|
|
258
|
-
embeddings:
|
|
259
|
-
modelProvider:
|
|
260
|
-
model:
|
|
261
|
-
dimensions:
|
|
262
|
-
templates:
|
|
263
|
-
layer:
|
|
264
|
-
field:
|
|
273
|
+
Description: {description}`, Pe = o.object({
|
|
274
|
+
schemaVersion: o.literal(de),
|
|
275
|
+
modified: o.number().int().nonnegative(),
|
|
276
|
+
embeddings: o.object({
|
|
277
|
+
modelProvider: o.literal(pe),
|
|
278
|
+
model: o.literal(me),
|
|
279
|
+
dimensions: o.literal(w),
|
|
280
|
+
templates: o.object({
|
|
281
|
+
layer: o.string().default(ue),
|
|
282
|
+
field: o.string().default(ge)
|
|
265
283
|
})
|
|
266
284
|
}),
|
|
267
|
-
layers:
|
|
268
|
-
|
|
269
|
-
id:
|
|
270
|
-
name:
|
|
271
|
-
title:
|
|
272
|
-
description:
|
|
273
|
-
vector:
|
|
285
|
+
layers: o.array(
|
|
286
|
+
o.object({
|
|
287
|
+
id: o.string().min(1),
|
|
288
|
+
name: o.string().min(1),
|
|
289
|
+
title: o.string().catch(""),
|
|
290
|
+
description: o.string().catch(""),
|
|
291
|
+
vector: o.array(o.number()).length(w, {
|
|
274
292
|
message: `Layer vector must be exactly ${w} dimensions`
|
|
275
293
|
}),
|
|
276
|
-
fields:
|
|
277
|
-
|
|
278
|
-
name:
|
|
279
|
-
alias:
|
|
280
|
-
description:
|
|
281
|
-
vector:
|
|
294
|
+
fields: o.array(
|
|
295
|
+
o.object({
|
|
296
|
+
name: o.string().min(1),
|
|
297
|
+
alias: o.string().catch(""),
|
|
298
|
+
description: o.string().catch(""),
|
|
299
|
+
vector: o.array(o.number()).length(w, {
|
|
282
300
|
message: `Field vector must be exactly ${w} dimensions`
|
|
283
301
|
})
|
|
284
302
|
})
|
|
285
303
|
)
|
|
286
304
|
})
|
|
287
305
|
).default([])
|
|
288
|
-
}),
|
|
306
|
+
}), fe = (e) => {
|
|
289
307
|
const t = /* @__PURE__ */ new Set();
|
|
290
308
|
for (const n of e)
|
|
291
|
-
if (
|
|
309
|
+
if (H(n)) {
|
|
292
310
|
const i = n;
|
|
293
|
-
i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((
|
|
294
|
-
|
|
311
|
+
i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((r) => {
|
|
312
|
+
r.id && t.add(r.id);
|
|
295
313
|
});
|
|
296
314
|
}
|
|
297
315
|
return e.filter((n) => {
|
|
298
|
-
if (
|
|
316
|
+
if (J(n)) {
|
|
299
317
|
const i = n;
|
|
300
318
|
return t.has(i.tool_call_id);
|
|
301
319
|
}
|
|
302
320
|
return !0;
|
|
303
321
|
});
|
|
304
|
-
},
|
|
305
|
-
const s =
|
|
306
|
-
return
|
|
307
|
-
},
|
|
308
|
-
const { promptText: t, modelTier: s, temperature: n, messages: i } = e,
|
|
309
|
-
return
|
|
310
|
-
},
|
|
311
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables:
|
|
322
|
+
}, I = (e, t) => {
|
|
323
|
+
const s = B.fromTemplate(e);
|
|
324
|
+
return F.fromMessages([s, ...t]);
|
|
325
|
+
}, he = async (e) => {
|
|
326
|
+
const { promptText: t, modelTier: s, temperature: n, messages: i, abortSignal: r } = e, a = I(t, i ?? []), c = await b({ modelTier: s, temperature: n, abortSignal: r });
|
|
327
|
+
return a.pipe(c);
|
|
328
|
+
}, qe = async (e) => {
|
|
329
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: r, abortSignal: a } = e, l = await (await he({
|
|
312
330
|
promptText: t,
|
|
313
331
|
modelTier: s,
|
|
314
332
|
temperature: n,
|
|
315
|
-
messages: i
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
messages: i,
|
|
334
|
+
abortSignal: a
|
|
335
|
+
})).invoke(r ?? {});
|
|
336
|
+
if (typeof l == "string")
|
|
337
|
+
return l;
|
|
338
|
+
const m = l.content;
|
|
339
|
+
return typeof m == "string" ? m : JSON.stringify(m);
|
|
340
|
+
}, V = async (e) => {
|
|
341
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: r, schema: a, abortSignal: c } = e, l = I(t, i ?? []), u = (await b({ modelTier: s, temperature: n, abortSignal: c })).withStructuredOutput(a);
|
|
342
|
+
return await l.pipe(u).invoke(r ?? {});
|
|
343
|
+
}, je = async (e) => {
|
|
344
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: r, tools: a, abortSignal: c } = e, l = a.length > 0 ? fe(i ?? []) : i ?? [], m = I(t, l), u = await b({ modelTier: s, temperature: n, abortSignal: c });
|
|
345
|
+
return await m.pipe(u.bindTools(a)).invoke(r ?? {});
|
|
346
|
+
}, ye = p.object({
|
|
328
347
|
name: p.string(),
|
|
329
348
|
description: p.string(),
|
|
330
349
|
valueType: p.string(),
|
|
331
350
|
alias: p.string()
|
|
332
|
-
}),
|
|
333
|
-
fields: p.array(
|
|
334
|
-
}),
|
|
335
|
-
const s =
|
|
351
|
+
}), we = p.object({
|
|
352
|
+
fields: p.array(ye)
|
|
353
|
+
}), z = (e, t) => e.getFieldAlias(t) ?? void 0, M = (e, t) => z(e, t.name) ?? t.alias ?? "", be = (e, t) => {
|
|
354
|
+
const s = z(e, t.name);
|
|
336
355
|
return !!(s && s !== (t.alias ?? ""));
|
|
337
356
|
};
|
|
338
|
-
function
|
|
357
|
+
function D(e, t) {
|
|
339
358
|
const s = /* @__PURE__ */ new Map();
|
|
340
359
|
for (const n of e.fields) {
|
|
341
|
-
const i = t.fields.find((l) => l.name === n.name),
|
|
360
|
+
const i = t.fields.find((l) => l.name === n.name), r = M(e, n), a = be(e, n), c = {
|
|
342
361
|
name: n.name,
|
|
343
362
|
type: n.type,
|
|
344
|
-
alias: a ?
|
|
363
|
+
alias: a ? r : i?.alias ?? r,
|
|
345
364
|
description: i?.description ?? n.description ?? "",
|
|
346
365
|
valueType: i?.valueType ?? n.valueType ?? "",
|
|
347
366
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
@@ -350,64 +369,65 @@ function R(e, t) {
|
|
|
350
369
|
}
|
|
351
370
|
return s;
|
|
352
371
|
}
|
|
353
|
-
const
|
|
354
|
-
const s = await
|
|
355
|
-
const { name: c, type: l, description: m } = a,
|
|
356
|
-
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${
|
|
372
|
+
const $e = async (e) => {
|
|
373
|
+
const s = await E("field_descriptions_prompt"), n = e.fields.filter((a) => !(M(e, a) && a.description)).map((a) => {
|
|
374
|
+
const { name: c, type: l, description: m } = a, u = M(e, a);
|
|
375
|
+
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${u}`, `Description: ${m ?? "N/A"}`].join(", ");
|
|
357
376
|
}).join(`
|
|
358
377
|
`);
|
|
359
378
|
if (n.length === 0)
|
|
360
|
-
return
|
|
379
|
+
return D(e, { fields: [] });
|
|
361
380
|
const i = {
|
|
362
381
|
existingItemTitle: e.portalItem?.title,
|
|
363
382
|
existingItemDescription: e.portalItem?.description,
|
|
364
383
|
existingLayerTitle: e.title,
|
|
365
384
|
existingLayerDescription: e.portalItem?.description,
|
|
366
385
|
fieldInformation: n
|
|
367
|
-
},
|
|
386
|
+
}, r = await V({
|
|
368
387
|
promptText: s,
|
|
369
|
-
schema:
|
|
388
|
+
schema: we,
|
|
370
389
|
inputVariables: i
|
|
371
390
|
});
|
|
372
|
-
return
|
|
373
|
-
},
|
|
391
|
+
return D(e, r);
|
|
392
|
+
}, xe = p.object({
|
|
374
393
|
title: p.string(),
|
|
375
394
|
description: p.string(),
|
|
376
395
|
name: p.string().nullable()
|
|
377
|
-
}),
|
|
378
|
-
const n = await
|
|
396
|
+
}), Ne = async (e, t) => {
|
|
397
|
+
const n = await E("layer_descriptions_prompt"), i = Array.from(t.values()), r = {
|
|
379
398
|
fieldInformation: JSON.stringify(i, null, 2),
|
|
380
399
|
existingLayerTitle: e.title,
|
|
381
400
|
existingLayerDescription: e.portalItem?.description,
|
|
382
401
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
383
402
|
layerGeometryType: e.geometryType
|
|
384
403
|
};
|
|
385
|
-
return { ...await
|
|
404
|
+
return { ...await V({
|
|
386
405
|
promptText: n,
|
|
387
|
-
schema:
|
|
388
|
-
inputVariables:
|
|
406
|
+
schema: xe,
|
|
407
|
+
inputVariables: r
|
|
389
408
|
}), name: e.title ?? null };
|
|
390
409
|
};
|
|
391
410
|
export {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
411
|
+
De as D,
|
|
412
|
+
Pe as W,
|
|
413
|
+
Ne as a,
|
|
414
|
+
pe as b,
|
|
415
|
+
b as c,
|
|
397
416
|
w as d,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
417
|
+
de as e,
|
|
418
|
+
ge as f,
|
|
419
|
+
$e as g,
|
|
420
|
+
qe as h,
|
|
421
|
+
V as i,
|
|
422
|
+
je as j,
|
|
423
|
+
se as k,
|
|
424
|
+
ue as l,
|
|
425
|
+
me as m,
|
|
426
|
+
Re as n,
|
|
427
|
+
Fe as o,
|
|
428
|
+
ne as p,
|
|
429
|
+
re as q,
|
|
430
|
+
_e as r,
|
|
431
|
+
g as s,
|
|
432
|
+
Ue as t
|
|
413
433
|
};
|