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