@arcgis/ai-components 5.2.0-next.65 → 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/{GLOALVJR.js → 563R6SX5.js} +1 -1
- package/dist/cdn/B6CJG5UH.js +66 -0
- package/dist/cdn/{3YCSUTGV.js → CXW5URTF.js} +1 -1
- package/dist/cdn/{L4SS54EZ.js → DTIVDIDY.js} +1 -1
- package/dist/cdn/{AYMUK2MC.js → E5ZKBC24.js} +2 -2
- package/dist/cdn/{7NP7WGR5.js → EKZTQFYI.js} +1 -1
- package/dist/cdn/{FVDFPK3V.js → GP6NDTUE.js} +1 -1
- package/dist/cdn/{LUJCH5V7.js → HTBMJ557.js} +1 -1
- package/dist/cdn/{THXUE6R4.js → JMIXLFSZ.js} +1 -1
- package/dist/cdn/{BI3LK5D3.js → KJAWV5SK.js} +1 -1
- package/dist/cdn/KQHLOYKL.js +3 -0
- package/dist/cdn/{QBINZNXI.js → KX43Z26W.js} +1 -1
- package/dist/cdn/{QZLE7B6X.js → MBIIANTX.js} +1 -1
- package/dist/cdn/{FC45FF2D.js → MW5S2XCB.js} +1 -1
- package/dist/cdn/{275NKWUE.js → PUFTYLJ2.js} +1 -1
- package/dist/cdn/{AHLLB5QW.js → QXGXNOTJ.js} +1 -1
- package/dist/cdn/{OY2P2O47.js → ST5FQYT7.js} +32 -32
- package/dist/cdn/{WHOZT5H5.js → SXHH575T.js} +17 -17
- package/dist/cdn/{RAAV47KU.js → UAKSN7EQ.js} +1 -1
- package/dist/cdn/{NSER3L4A.js → WVPU4QOO.js} +1 -1
- package/dist/cdn/{242OOJML.js → Y2JULDNA.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +2 -2
- package/dist/chunks/generateLayerDescriptions.js +200 -189
- package/dist/chunks/navigationGraph.js +21 -20
- package/dist/chunks/orchestrator.js +221 -193
- 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 +1 -0
- package/package.json +6 -6
- package/dist/cdn/FNPLHH4E.js +0 -3
- package/dist/cdn/NQROZZHC.js +0 -65
|
@@ -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,61 +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
|
-
|
|
94
|
+
routing: m({
|
|
95
|
+
default: () => ({ mode: "auto" }),
|
|
96
|
+
reducer: f
|
|
97
|
+
}),
|
|
98
|
+
lastExecutedAgent: m({
|
|
95
99
|
default: () => "",
|
|
96
|
-
reducer:
|
|
100
|
+
reducer: f
|
|
97
101
|
}),
|
|
98
|
-
requiresFollowUp:
|
|
102
|
+
requiresFollowUp: m({
|
|
99
103
|
default: () => !0,
|
|
100
|
-
reducer:
|
|
104
|
+
reducer: f
|
|
101
105
|
}),
|
|
102
|
-
stepCount:
|
|
106
|
+
stepCount: m({
|
|
103
107
|
default: () => 0,
|
|
104
108
|
reducer: (e, t) => t ?? e + 1
|
|
105
109
|
}),
|
|
106
|
-
finalOutputMessage:
|
|
110
|
+
finalOutputMessage: m({
|
|
107
111
|
default: () => "",
|
|
108
112
|
reducer: $
|
|
109
113
|
})
|
|
@@ -117,7 +121,7 @@ ${s}`;
|
|
|
117
121
|
return ae(t) ? t : void 0;
|
|
118
122
|
}, le = (e, t, s) => {
|
|
119
123
|
const n = e[t];
|
|
120
|
-
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) => {
|
|
121
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." : ""))));
|
|
122
126
|
});
|
|
123
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) => {
|
|
@@ -128,34 +132,41 @@ ${s}`;
|
|
|
128
132
|
},
|
|
129
133
|
n
|
|
130
134
|
)).structuredResponse };
|
|
131
|
-
},
|
|
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) => {
|
|
132
136
|
const t = e?.configurable;
|
|
133
137
|
return {
|
|
134
|
-
conversationId:
|
|
138
|
+
conversationId: pe(t?.thread_id),
|
|
135
139
|
abortSignal: e?.signal,
|
|
136
|
-
requestId:
|
|
140
|
+
requestId: me(),
|
|
137
141
|
requestSource: ue(ne.applicationName)
|
|
138
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)}`);
|
|
139
149
|
}, N = async ({ config: e }) => {
|
|
140
150
|
const t = F.getDefault(), n = (await ee.getCredential(`${t.url}/sharing`))?.token;
|
|
141
|
-
return async (
|
|
142
|
-
const { conversationId: a, abortSignal: c, requestId: l, requestSource: d } = ge(e),
|
|
143
|
-
for (const
|
|
144
|
-
const
|
|
145
|
-
(
|
|
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);
|
|
146
156
|
}
|
|
147
|
-
n && n.length > 0 &&
|
|
148
|
-
const
|
|
149
|
-
return await
|
|
150
|
-
|
|
151
|
-
headers:
|
|
152
|
-
|
|
153
|
-
|
|
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;
|
|
154
165
|
};
|
|
155
|
-
},
|
|
156
|
-
const { modelTier: t = "default", temperature: s = 0, config: n } = e,
|
|
157
|
-
return new
|
|
158
|
-
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,
|
|
159
170
|
apiKey: "dummy-key",
|
|
160
171
|
// 5-mini does not support temperature parameter
|
|
161
172
|
...t !== "default" && { temperature: s },
|
|
@@ -164,71 +175,71 @@ ${s}`;
|
|
|
164
175
|
fetch: await N({ config: n })
|
|
165
176
|
}
|
|
166
177
|
});
|
|
167
|
-
},
|
|
168
|
-
const { tier: t = "default", config: s } = e, n = E[t],
|
|
169
|
-
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({
|
|
170
181
|
modelName: n,
|
|
171
182
|
apiKey: "dummy-key",
|
|
172
183
|
configuration: {
|
|
173
|
-
baseURL:
|
|
184
|
+
baseURL: r,
|
|
174
185
|
fetch: await N({ config: s })
|
|
175
186
|
},
|
|
176
187
|
batchSize: 2048,
|
|
177
188
|
maxConcurrency: 10
|
|
178
189
|
});
|
|
179
|
-
},
|
|
180
|
-
id:
|
|
181
|
-
name:
|
|
182
|
-
description:
|
|
190
|
+
}, he = i.object({
|
|
191
|
+
id: i.string().min(1),
|
|
192
|
+
name: i.string().min(1),
|
|
193
|
+
description: i.string().min(1)
|
|
183
194
|
});
|
|
184
|
-
|
|
185
|
-
const C = (e) => JSON.stringify(e, null, 2),
|
|
186
|
-
const t = e.map((n) => n.id), s =
|
|
187
|
-
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({
|
|
188
199
|
intent: s.nullable(),
|
|
189
|
-
assignedTask:
|
|
190
|
-
requiresFollowUp:
|
|
200
|
+
assignedTask: i.string().nullable(),
|
|
201
|
+
requiresFollowUp: i.boolean()
|
|
191
202
|
});
|
|
192
|
-
},
|
|
203
|
+
}, Ke = async (e, t) => {
|
|
193
204
|
const s = ce(t);
|
|
194
205
|
if (t?.signal?.aborted)
|
|
195
|
-
return await
|
|
206
|
+
return await y({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
196
207
|
...e,
|
|
197
208
|
currentIntent: "none",
|
|
198
209
|
finalOutputMessage: "Operation cancelled.",
|
|
199
210
|
requiresFollowUp: !1
|
|
200
211
|
};
|
|
201
212
|
try {
|
|
202
|
-
await
|
|
203
|
-
const
|
|
204
|
-
id:
|
|
205
|
-
name:
|
|
206
|
-
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
|
|
207
218
|
}));
|
|
208
219
|
if (!o.length)
|
|
209
|
-
return await
|
|
220
|
+
return await y({ text: "No agents registered; skipping intent detection" }, t), {
|
|
210
221
|
...e,
|
|
211
222
|
currentIntent: "none",
|
|
212
223
|
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
213
224
|
};
|
|
214
|
-
const a = await R("intent_prompt"), c = C(o), l =
|
|
225
|
+
const a = await R("intent_prompt"), c = C(o), l = ye(o), d = {
|
|
215
226
|
registeredAgents: c,
|
|
216
227
|
priorSteps: C(e.agentExecutionContext.priorSteps),
|
|
217
228
|
userRequest: e.agentExecutionContext.userRequest
|
|
218
|
-
},
|
|
219
|
-
model: await
|
|
229
|
+
}, w = await D.fromTemplate(a).format(d), S = G({
|
|
230
|
+
model: await v({
|
|
220
231
|
modelTier: "fast",
|
|
221
232
|
config: t
|
|
222
233
|
}),
|
|
223
234
|
tools: [],
|
|
224
|
-
systemPrompt:
|
|
235
|
+
systemPrompt: w,
|
|
225
236
|
responseFormat: l,
|
|
226
237
|
middleware: [
|
|
227
238
|
// Preserve recent conversation context while summarizing older messages
|
|
228
239
|
// to control token usage without losing important intent signals.
|
|
229
240
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
230
|
-
|
|
231
|
-
model: await
|
|
241
|
+
J({
|
|
242
|
+
model: await v({
|
|
232
243
|
modelTier: "fast",
|
|
233
244
|
config: t
|
|
234
245
|
}),
|
|
@@ -237,36 +248,36 @@ const C = (e) => JSON.stringify(e, null, 2), he = (e) => {
|
|
|
237
248
|
}),
|
|
238
249
|
// Enforce no loop/retry.
|
|
239
250
|
// 1 usual LLM call and 1 optional summarization call.
|
|
240
|
-
|
|
251
|
+
Q({ runLimit: 2 })
|
|
241
252
|
]
|
|
242
|
-
}), { structuredResponse:
|
|
243
|
-
agent:
|
|
253
|
+
}), { structuredResponse: x } = await de({
|
|
254
|
+
agent: S,
|
|
244
255
|
messages: e.agentExecutionContext.messages,
|
|
245
256
|
config: t
|
|
246
|
-
}),
|
|
247
|
-
|
|
248
|
-
), T =
|
|
257
|
+
}), g = l.parse(
|
|
258
|
+
x ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
259
|
+
), T = g.intent ?? "none", V = {
|
|
249
260
|
...e,
|
|
250
261
|
currentIntent: T,
|
|
251
|
-
requiresFollowUp:
|
|
262
|
+
requiresFollowUp: g.requiresFollowUp,
|
|
252
263
|
agentExecutionContext: {
|
|
253
264
|
...e.agentExecutionContext,
|
|
254
|
-
assignedTask:
|
|
265
|
+
assignedTask: g.assignedTask ?? ""
|
|
255
266
|
}
|
|
256
267
|
};
|
|
257
268
|
if (T === "none") {
|
|
258
|
-
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(", ")}.
|
|
259
270
|
|
|
260
271
|
Please ask a question that can be answered by one of these agents.`;
|
|
261
|
-
return await
|
|
272
|
+
return await y({ text: "LLM did not identify a clear intent." }, t), {
|
|
262
273
|
...e,
|
|
263
274
|
currentIntent: T,
|
|
264
275
|
requiresFollowUp: !1,
|
|
265
|
-
finalOutputMessage:
|
|
276
|
+
finalOutputMessage: h,
|
|
266
277
|
agentExecutionContext: {
|
|
267
278
|
...e.agentExecutionContext,
|
|
268
279
|
assignedTask: "",
|
|
269
|
-
messages: [...e.agentExecutionContext.messages, new W(
|
|
280
|
+
messages: [...e.agentExecutionContext.messages, new W(h)],
|
|
270
281
|
priorSteps: [
|
|
271
282
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
272
283
|
{
|
|
@@ -279,49 +290,49 @@ Please ask a question that can be answered by one of these agents.`;
|
|
|
279
290
|
}
|
|
280
291
|
};
|
|
281
292
|
}
|
|
282
|
-
return await
|
|
293
|
+
return await y(
|
|
283
294
|
{
|
|
284
295
|
text: `Agent picked: ${T}
|
|
285
|
-
Task Assigned: ${
|
|
286
|
-
Requires Follow-Up: ${
|
|
296
|
+
Task Assigned: ${g.assignedTask ?? ""}
|
|
297
|
+
Requires Follow-Up: ${g.requiresFollowUp}`
|
|
287
298
|
},
|
|
288
299
|
t
|
|
289
|
-
),
|
|
300
|
+
), V;
|
|
290
301
|
} catch (n) {
|
|
291
|
-
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)}`);
|
|
292
303
|
}
|
|
293
|
-
},
|
|
304
|
+
}, we = "0.1", b = 1536, be = "openai", ve = E.default, xe = `Name: {name}
|
|
294
305
|
Title: {title}
|
|
295
|
-
Description: {description}`,
|
|
306
|
+
Description: {description}`, Te = `Name: {name}
|
|
296
307
|
Alias: {alias}
|
|
297
|
-
Description: {description}`,
|
|
298
|
-
schemaVersion:
|
|
299
|
-
modified:
|
|
300
|
-
embeddings:
|
|
301
|
-
modelProvider:
|
|
302
|
-
model:
|
|
303
|
-
dimensions:
|
|
304
|
-
templates:
|
|
305
|
-
layer:
|
|
306
|
-
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)
|
|
307
318
|
})
|
|
308
319
|
}),
|
|
309
|
-
layers:
|
|
310
|
-
|
|
311
|
-
id:
|
|
312
|
-
name:
|
|
313
|
-
title:
|
|
314
|
-
description:
|
|
315
|
-
vector:
|
|
316
|
-
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`
|
|
317
328
|
}),
|
|
318
|
-
fields:
|
|
319
|
-
|
|
320
|
-
name:
|
|
321
|
-
alias:
|
|
322
|
-
description:
|
|
323
|
-
vector:
|
|
324
|
-
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`
|
|
325
336
|
})
|
|
326
337
|
})
|
|
327
338
|
)
|
|
@@ -330,63 +341,63 @@ Description: {description}`, Ke = r.object({
|
|
|
330
341
|
}), Me = (e) => {
|
|
331
342
|
const t = /* @__PURE__ */ new Set();
|
|
332
343
|
for (const n of e)
|
|
333
|
-
if (
|
|
334
|
-
const
|
|
335
|
-
|
|
344
|
+
if (H(n)) {
|
|
345
|
+
const r = n;
|
|
346
|
+
r.tool_calls && r.tool_calls.length > 0 && r.tool_calls.forEach((o) => {
|
|
336
347
|
o.id && t.add(o.id);
|
|
337
348
|
});
|
|
338
349
|
}
|
|
339
350
|
return e.filter((n) => {
|
|
340
351
|
if (X(n)) {
|
|
341
|
-
const
|
|
342
|
-
return t.has(
|
|
352
|
+
const r = n;
|
|
353
|
+
return t.has(r.tool_call_id);
|
|
343
354
|
}
|
|
344
355
|
return !0;
|
|
345
356
|
});
|
|
346
357
|
}, A = (e, t) => {
|
|
347
|
-
const s =
|
|
348
|
-
return
|
|
349
|
-
},
|
|
350
|
-
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 });
|
|
351
362
|
return a.pipe(c);
|
|
352
363
|
}, We = async (e) => {
|
|
353
|
-
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({
|
|
354
365
|
promptText: t,
|
|
355
366
|
modelTier: s,
|
|
356
367
|
temperature: n,
|
|
357
|
-
messages:
|
|
368
|
+
messages: r,
|
|
358
369
|
config: a
|
|
359
370
|
})).invoke(o ?? {}, a);
|
|
360
371
|
if (typeof l == "string")
|
|
361
372
|
return l;
|
|
362
373
|
const d = l.content;
|
|
363
374
|
return typeof d == "string" ? d : JSON.stringify(d);
|
|
364
|
-
},
|
|
365
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
366
|
-
return await l.pipe(
|
|
367
|
-
},
|
|
368
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
369
|
-
return await d.pipe(
|
|
370
|
-
},
|
|
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({
|
|
371
382
|
name: u.string(),
|
|
372
383
|
description: u.string(),
|
|
373
384
|
valueType: u.string(),
|
|
374
385
|
alias: u.string()
|
|
375
|
-
}),
|
|
376
|
-
fields: u.array(
|
|
377
|
-
}), 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) => {
|
|
378
389
|
const s = z(e, t.name);
|
|
379
390
|
return !!(s && s !== (t.alias ?? ""));
|
|
380
391
|
};
|
|
381
|
-
function
|
|
392
|
+
function q(e, t) {
|
|
382
393
|
const s = /* @__PURE__ */ new Map();
|
|
383
394
|
for (const n of e.fields) {
|
|
384
|
-
const
|
|
395
|
+
const r = t.fields.find((l) => l.name === n.name), o = I(e, n), a = Ee(e, n), c = {
|
|
385
396
|
name: n.name,
|
|
386
397
|
type: n.type,
|
|
387
|
-
alias: a ? o :
|
|
388
|
-
description:
|
|
389
|
-
valueType:
|
|
398
|
+
alias: a ? o : r?.alias ?? o,
|
|
399
|
+
description: r?.description ?? n.description ?? "",
|
|
400
|
+
valueType: r?.valueType ?? n.valueType ?? "",
|
|
390
401
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
391
402
|
};
|
|
392
403
|
s.set(n.name, c);
|
|
@@ -395,61 +406,61 @@ function D(e, t) {
|
|
|
395
406
|
}
|
|
396
407
|
const Xe = async (e) => {
|
|
397
408
|
const s = await R("field_descriptions_prompt"), n = e.fields.filter((a) => !(I(e, a) && a.description)).map((a) => {
|
|
398
|
-
const { name: c, type: l, description: d } = a,
|
|
399
|
-
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(", ");
|
|
400
411
|
}).join(`
|
|
401
412
|
`);
|
|
402
413
|
if (n.length === 0)
|
|
403
|
-
return
|
|
404
|
-
const
|
|
414
|
+
return q(e, { fields: [] });
|
|
415
|
+
const r = {
|
|
405
416
|
existingItemTitle: e.portalItem?.title,
|
|
406
417
|
existingItemDescription: e.portalItem?.description,
|
|
407
418
|
existingLayerTitle: e.title,
|
|
408
419
|
existingLayerDescription: e.portalItem?.description,
|
|
409
420
|
fieldInformation: n
|
|
410
|
-
}, o = await
|
|
421
|
+
}, o = await L({
|
|
411
422
|
promptText: s,
|
|
412
|
-
schema:
|
|
413
|
-
inputVariables:
|
|
423
|
+
schema: Ie,
|
|
424
|
+
inputVariables: r
|
|
414
425
|
});
|
|
415
|
-
return
|
|
416
|
-
},
|
|
426
|
+
return q(e, o);
|
|
427
|
+
}, Re = u.object({
|
|
417
428
|
title: u.string(),
|
|
418
429
|
description: u.string(),
|
|
419
430
|
name: u.string().nullable()
|
|
420
431
|
}), Ge = async (e, t) => {
|
|
421
|
-
const n = await R("layer_descriptions_prompt"),
|
|
422
|
-
fieldInformation: JSON.stringify(
|
|
432
|
+
const n = await R("layer_descriptions_prompt"), r = Array.from(t.values()), o = {
|
|
433
|
+
fieldInformation: JSON.stringify(r, null, 2),
|
|
423
434
|
existingLayerTitle: e.title,
|
|
424
435
|
existingLayerDescription: e.portalItem?.description,
|
|
425
436
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
426
437
|
layerGeometryType: e.geometryType
|
|
427
438
|
};
|
|
428
|
-
return { ...await
|
|
439
|
+
return { ...await L({
|
|
429
440
|
promptText: n,
|
|
430
|
-
schema:
|
|
441
|
+
schema: Re,
|
|
431
442
|
inputVariables: o
|
|
432
443
|
}), name: e.title ?? null };
|
|
433
444
|
};
|
|
434
445
|
export {
|
|
435
446
|
ze as D,
|
|
436
|
-
|
|
447
|
+
Be as W,
|
|
437
448
|
Ge as a,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
449
|
+
be as b,
|
|
450
|
+
v as c,
|
|
451
|
+
b as d,
|
|
441
452
|
We as e,
|
|
442
|
-
|
|
453
|
+
Te as f,
|
|
443
454
|
Xe as g,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
455
|
+
He as h,
|
|
456
|
+
L as i,
|
|
457
|
+
ie as j,
|
|
458
|
+
Le as k,
|
|
459
|
+
xe as l,
|
|
460
|
+
ve as m,
|
|
450
461
|
oe as n,
|
|
451
462
|
ce as o,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
463
|
+
Ke as p,
|
|
464
|
+
Ve as q,
|
|
465
|
+
we as s
|
|
455
466
|
};
|