@arcgis/ai-components 5.1.0-next.4 → 5.1.0-next.41
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/24MYCR6F.js +3 -0
- package/dist/cdn/2JJGDGMG.js +67 -0
- package/dist/cdn/433QN6BZ.js +2 -0
- package/dist/cdn/{R3LASMEM.js → 6Z5UQ3RY.js} +106 -107
- package/dist/cdn/75CJ2C4L.js +2 -0
- package/dist/cdn/7ITNTTBI.js +2 -0
- package/dist/cdn/{CN6VFVA2.js → BSIB6MUI.js} +1 -0
- package/dist/cdn/COBFCTOX.js +2 -0
- package/dist/cdn/CXBXMIVC.js +2 -0
- package/dist/cdn/{UY4FI7AP.js → FHXNY4QC.js} +1 -1
- package/dist/cdn/HN2XKXPX.js +2 -0
- package/dist/cdn/HRAAW2JX.js +2 -0
- package/dist/cdn/NCO7XIEC.js +3 -0
- package/dist/cdn/OG537NIF.js +2 -0
- package/dist/cdn/RNZITNTO.js +2 -0
- package/dist/cdn/{62K6RJZZ.js → SA7B3M2J.js} +1 -1
- package/dist/cdn/TBEVPWWN.js +2 -0
- package/dist/cdn/UIXYUELQ.js +2 -0
- package/dist/cdn/UY42NIH7.js +2 -0
- package/dist/cdn/VC3I52HI.js +2 -0
- package/dist/cdn/{ZYQ6U2YH.js → VDUOWASW.js} +14 -0
- package/dist/cdn/{NKNUZCLA.js → W2A22QZU.js} +15 -0
- package/dist/cdn/XI5SV3HJ.js +47 -0
- package/dist/cdn/XSVSCXUM.js +2 -0
- package/dist/cdn/XUUCW7HH.js +2 -0
- package/dist/cdn/{M7XUI5KY.js → Z6ZNHTPJ.js} +35 -3
- package/dist/cdn/ZF5LIGCC.js +275 -0
- package/dist/cdn/ZPGX72R2.js +4 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/converterUtils.js +117 -0
- package/dist/chunks/utils.js +16 -14
- package/dist/chunks/utils2.js +8 -3
- package/dist/components/arcgis-assistant/customElement.d.ts +286 -23
- package/dist/components/arcgis-assistant/customElement.js +172 -142
- package/dist/components/arcgis-assistant/index.js +2 -1
- package/dist/components/arcgis-assistant/types.d.ts +97 -0
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +22 -8
- package/dist/components/arcgis-assistant-agent/customElement.js +7 -7
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -6
- package/dist/components/arcgis-assistant-chat/customElement.js +14 -14
- package/dist/components/arcgis-assistant-chat-card/customElement.d.ts +12 -5
- package/dist/components/arcgis-assistant-chat-card/customElement.js +59 -25
- package/dist/components/arcgis-assistant-chat-card/index.js +2 -0
- package/dist/components/arcgis-assistant-chat-card-content/customElement.js +14 -12
- package/dist/components/arcgis-assistant-chat-card-content/index.js +1 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +5 -2
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +42 -20
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.d.ts +73 -6
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +5 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.d.ts +73 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +26 -0
- package/dist/components/arcgis-assistant-help-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-help-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +8 -8
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.js +3 -3
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.js +10 -10
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +6 -6
- package/dist/components/arcgis-assistant-navigation-agent/customElement.d.ts +53 -6
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +5 -5
- package/dist/components/arcgis-assistant-shell/customElement.d.ts +3 -0
- package/dist/components/arcgis-assistant-shell/customElement.js +12 -11
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/loader.js +9 -8
- package/dist/types/lumina.d.ts +19 -5
- package/dist/types/preact.d.ts +20 -5
- package/dist/types/react.d.ts +21 -5
- package/dist/types/stencil.d.ts +19 -5
- package/dist/utils/index.d.ts +305 -0
- package/dist/utils/index.js +13 -0
- package/package.json +15 -8
- package/dist/cdn/26V7SXDR.js +0 -4
- package/dist/cdn/4Y73V2HU.js +0 -2
- package/dist/cdn/5DFZMIRZ.js +0 -2
- package/dist/cdn/6ULHJSIQ.js +0 -245
- package/dist/cdn/AQZDEJJZ.js +0 -2
- package/dist/cdn/GCFT45CD.js +0 -2
- package/dist/cdn/I22GHLAO.js +0 -2
- package/dist/cdn/IFWK7P7O.js +0 -2
- package/dist/cdn/KJZARHAM.js +0 -2
- package/dist/cdn/M672SFG6.js +0 -2
- package/dist/cdn/MLJ7GXKB.js +0 -2
- package/dist/cdn/PCBMGVNZ.js +0 -4
- package/dist/cdn/Q674OE2M.js +0 -2
- package/dist/cdn/QOIX2B5M.js +0 -2
- package/dist/cdn/SOWNHB7F.js +0 -30
- package/dist/cdn/SW3IAT6V.js +0 -2
- package/dist/cdn/VUHDKXFM.js +0 -2
- package/dist/cdn/XVUE27HC.js +0 -2
- package/dist/cdn/ZFFHP5DI.js +0 -2
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
2
|
import type Collection from "@arcgis/core/core/Collection.js";
|
|
3
3
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
4
|
+
import type { ChatMessage } from "../arcgis-assistant/types.js";
|
|
4
5
|
|
|
5
6
|
/** @internal */
|
|
6
7
|
export abstract class ArcgisAssistantChat extends LitElement {
|
|
8
|
+
/** @default false */
|
|
9
|
+
accessor copyEnabled: boolean;
|
|
10
|
+
/** @default false */
|
|
11
|
+
accessor feedbackEnabled: boolean;
|
|
7
12
|
/** @default false */
|
|
8
13
|
accessor loading: boolean;
|
|
9
14
|
/** @default "" */
|
|
10
15
|
accessor loadingMessage: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
log?: string;
|
|
15
|
-
error?: string;
|
|
16
|
-
}>;
|
|
16
|
+
/** @default false */
|
|
17
|
+
accessor logEnabled: boolean;
|
|
18
|
+
accessor messages: Collection<ChatMessage>;
|
|
17
19
|
accessor user: string | undefined;
|
|
18
20
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
2
|
+
import { c as e } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as t, html as s } from "lit";
|
|
4
4
|
import { LitElement as i } from "@arcgis/lumina";
|
|
5
|
-
import { createRef as
|
|
6
|
-
import
|
|
7
|
-
import { watch as
|
|
8
|
-
const
|
|
9
|
-
class
|
|
5
|
+
import { createRef as l, ref as n } from "lit/directives/ref.js";
|
|
6
|
+
import o from "@arcgis/core/core/Collection.js";
|
|
7
|
+
import { watch as c } from "@arcgis/core/core/reactiveUtils.js";
|
|
8
|
+
const d = t`.assistant-chat__messages-container{display:flex;flex:1;flex-direction:column}.assistant-chat__messages-list{padding:var(--calcite-spacing-lg);display:flex;flex-direction:column;gap:var(--calcite-spacing-md);flex:1 1 auto;min-height:0;justify-content:flex-end;overflow:auto}`;
|
|
9
|
+
class r extends i {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.#s =
|
|
11
|
+
super(...arguments), this.#s = l(), this.feedbackEnabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.loading = !1, this.loadingMessage = "", this.messages = new o([]);
|
|
12
12
|
}
|
|
13
13
|
static {
|
|
14
|
-
this.properties = { loading: 5, loadingMessage: 1, user: 1, messages: 0 };
|
|
14
|
+
this.properties = { feedbackEnabled: 5, logEnabled: 5, copyEnabled: 5, loading: 5, loadingMessage: 1, user: 1, messages: 0 };
|
|
15
15
|
}
|
|
16
16
|
static {
|
|
17
|
-
this.styles =
|
|
17
|
+
this.styles = d;
|
|
18
18
|
}
|
|
19
19
|
#s;
|
|
20
20
|
firstUpdated() {
|
|
@@ -25,7 +25,7 @@ class d extends i {
|
|
|
25
25
|
this.messages.on("change", () => {
|
|
26
26
|
this.requestUpdate(), this._scrollToEnd();
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
c(() => this.loading, () => {
|
|
29
29
|
this._scrollToEnd();
|
|
30
30
|
})
|
|
31
31
|
]);
|
|
@@ -36,10 +36,10 @@ class d extends i {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
|
-
return
|
|
39
|
+
return s`<div class="assistant-chat__messages-container"><div class="assistant-chat__messages-list"><slot></slot>${this.messages.map((a) => s`<arcgis-assistant-chat-card .message=${a} .user=${this.user} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled}></arcgis-assistant-chat-card>`)}${this.loading ? s`<arcgis-assistant-chat-card .loading=${this.loading} .loadingMessage=${this.loadingMessage} .message=${{ id: "loading", role: "assistant", content: this.loadingMessage }}></arcgis-assistant-chat-card>` : null}</div><div ${n(this.#s)}></div></div>`;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
e("arcgis-assistant-chat", r);
|
|
43
43
|
export {
|
|
44
|
-
|
|
44
|
+
r as ArcgisAssistantChat
|
|
45
45
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
2
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
3
|
+
import type { AssistantMessage, ChatMessage } from "../arcgis-assistant/types.js";
|
|
3
4
|
import type { T9nMeta } from "@arcgis/lumina/controllers";
|
|
4
5
|
|
|
5
6
|
/** @internal */
|
|
@@ -17,16 +18,22 @@ export abstract class ArcgisAssistantChatCard extends LitElement {
|
|
|
17
18
|
logButtonLabel: string;
|
|
18
19
|
}>;
|
|
19
20
|
accessor content: string | undefined;
|
|
21
|
+
/** @default false */
|
|
22
|
+
accessor copyEnabled: boolean;
|
|
20
23
|
accessor error: string | undefined;
|
|
21
24
|
/** @default false */
|
|
22
|
-
accessor
|
|
25
|
+
accessor feedbackEnabled: boolean;
|
|
23
26
|
/** @default false */
|
|
24
27
|
accessor loading: boolean;
|
|
25
28
|
accessor loadingMessage: string | undefined;
|
|
26
|
-
accessor log: string | undefined;
|
|
29
|
+
accessor log: string[] | undefined;
|
|
27
30
|
/** @default false */
|
|
28
|
-
accessor
|
|
29
|
-
|
|
30
|
-
accessor
|
|
31
|
+
accessor logEnabled: boolean;
|
|
32
|
+
accessor message: ChatMessage | undefined;
|
|
33
|
+
accessor messageRole: ChatMessage["role"] | undefined;
|
|
31
34
|
accessor user: string | undefined;
|
|
35
|
+
readonly arcgisFeedback: import("@arcgis/lumina").TargetedEvent<this, AssistantMessage>;
|
|
36
|
+
readonly "@eventTypes": {
|
|
37
|
+
arcgisFeedback: ArcgisAssistantChatCard["arcgisFeedback"]["detail"];
|
|
38
|
+
};
|
|
32
39
|
}
|
|
@@ -1,53 +1,87 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
4
|
-
import { LitElement as
|
|
5
|
-
import { u as
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { c as s } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as i, html as e } from "lit";
|
|
4
|
+
import { LitElement as c, createEvent as o } from "@arcgis/lumina";
|
|
5
|
+
import { u as n } from "../../chunks/useT9n.js";
|
|
6
|
+
import { unsafeHTML as r } from "lit/directives/unsafe-html.js";
|
|
7
|
+
import { createRef as l, ref as d } from "lit/directives/ref.js";
|
|
8
|
+
import { p as h } from "../../chunks/converterUtils.js";
|
|
9
|
+
import { watch as g } from "@arcgis/core/core/reactiveUtils.js";
|
|
10
|
+
const p = i`:host{display:block;container-type:inline-size}.assistant-chat-card__prompt-container{display:flex;align-items:center;gap:var(--calcite-spacing-md);background:color-mix(in srgb,var(--calcite-color-brand) 25%,transparent);color:var(--calcite-color-text-1);padding:var(--calcite-spacing-md);border-radius:var(--calcite-border-radius);width:fit-content;margin-left:auto;justify-content:flex-end}.assistant-chat-card__prompt-avatar{display:flex;align-items:center;justify-content:center}.assistant-chat-card__content-container{display:flex;flex:1;flex-direction:column;width:100%}.assistant-chat-card__response-container{display:flex;flex-direction:column;align-items:flex-start;gap:var(--calcite-spacing-sm);width:100%;text-align:left}.assistant-chat-card__response-icon{padding:var(--calcite-spacing-sm);border-radius:var(--calcite-spacing-xl);background:var(--calcite-color-brand);color:var(--calcite-color-foreground-1)}.assistant-chat-card__footer{display:flex;width:100%;justify-content:space-between;padding:0 var(--calcite-spacing-xxs)}.assistant-chat-card__feedback-actions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xxs)}.assistant-chat-card__log-container{padding:0 var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);margin-bottom:var(--calcite-spacing-sm)}.assistant-chat-card__log{margin:0;background-color:var(--calcite-color-foreground-1);width:100%;max-height:300px;overflow:auto}.assistant-chat-card__log-entry{margin-left:var(--calcite-spacing-sm);padding:var(--calcite-spacing-xxs) var(--calcite-spacing-lg);border-left:1px solid var(--calcite-color-border-1)}.assistant-chat-card__footer-start,.assistant-chat-card__footer-end{display:flex;gap:var(--calcite-spacing-xxs)}@container (min-width: 480px){.assistant-chat-card__prompt-container,.assistant-chat-card__response-container{max-width:80%}}`;
|
|
11
|
+
class _ extends c {
|
|
8
12
|
constructor() {
|
|
9
|
-
super(...arguments), this._messages =
|
|
13
|
+
super(...arguments), this._messages = n({ blocking: !0 }), this._endRef = l(), this._showLog = !1, this.loading = !1, this.feedbackEnabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.arcgisFeedback = o();
|
|
10
14
|
}
|
|
11
15
|
static {
|
|
12
|
-
this.properties = { _showLog: 16, loading: 5,
|
|
16
|
+
this.properties = { _showLog: 16, _role: 16, _content: 16, _log: 16, _error: 16, _feedback: 16, loading: 5, messageRole: 1, feedbackEnabled: 5, logEnabled: 5, copyEnabled: 5, content: 1, loadingMessage: 1, log: 0, error: 1, user: 1, message: 0 };
|
|
13
17
|
}
|
|
14
18
|
static {
|
|
15
|
-
this.styles =
|
|
19
|
+
this.styles = p;
|
|
20
|
+
}
|
|
21
|
+
get _role() {
|
|
22
|
+
return this.message?.role ?? this.messageRole;
|
|
23
|
+
}
|
|
24
|
+
get _content() {
|
|
25
|
+
return this.message?.content ?? this.content;
|
|
26
|
+
}
|
|
27
|
+
get _log() {
|
|
28
|
+
return (this.message?.role === "assistant" ? this.message?.log : void 0) ?? this.log;
|
|
29
|
+
}
|
|
30
|
+
get _error() {
|
|
31
|
+
return (this.message?.role === "assistant" ? this.message?.error : void 0) ?? this.error;
|
|
32
|
+
}
|
|
33
|
+
get _feedback() {
|
|
34
|
+
return this.message?.role === "assistant" ? this.message?.feedback?.positive : void 0;
|
|
35
|
+
}
|
|
36
|
+
loaded() {
|
|
37
|
+
this.manager.onLifecycle(() => [
|
|
38
|
+
g(() => this._showLog, () => this._scrollToEnd())
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
_scrollToEnd() {
|
|
42
|
+
requestAnimationFrame(() => {
|
|
43
|
+
this._endRef.value?.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
_handleFeedback(t) {
|
|
47
|
+
this.message?.role === "assistant" && (this.message.feedback = this.message.feedback?.positive === t ? void 0 : { positive: t }, this.arcgisFeedback.emit(this.message), this.requestUpdate());
|
|
16
48
|
}
|
|
17
49
|
_renderLog() {
|
|
18
|
-
return this.
|
|
50
|
+
return this._log && this._showLog && this.logEnabled ? e`<div class="assistant-chat-card__log-container"><div class="assistant-chat-card__log"><calcite-accordion appearance=transparent icon-position=start icon-type=chevron scale=s>${this._log.map((t) => {
|
|
51
|
+
const a = t.includes(`
|
|
52
|
+
`) || t.length > 70;
|
|
53
|
+
return e`<calcite-accordion-item .heading=${a ? `${t.substring(0, 70)}...` : t} .expanded=${a}><div class="assistant-chat-card__log-entry">${a ? r(h(t)) : null}</div></calcite-accordion-item>`;
|
|
54
|
+
})}</calcite-accordion></div></div>` : null;
|
|
19
55
|
}
|
|
20
56
|
_renderThumbsUpButton() {
|
|
21
|
-
return
|
|
22
|
-
}} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`;
|
|
57
|
+
return e`<calcite-action id=action-thumbs-up icon=thumbs-up scale=s .active=${this._feedback === !0} @click=${() => this._handleFeedback(!0)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`;
|
|
23
58
|
}
|
|
24
59
|
_renderThumbsDownButton() {
|
|
25
|
-
return
|
|
26
|
-
}} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`;
|
|
60
|
+
return e`<calcite-action id=action-thumbs-down icon=thumbs-down scale=s .active=${this._feedback === !1} @click=${() => this._handleFeedback(!1)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`;
|
|
27
61
|
}
|
|
28
62
|
_renderFeedback() {
|
|
29
|
-
return
|
|
63
|
+
return this.feedbackEnabled && !this._error ? e`<div class="assistant-chat-card__feedback-actions">${this._renderThumbsUpButton()}${this._renderThumbsDownButton()}</div>` : null;
|
|
30
64
|
}
|
|
31
65
|
_renderCopyButton() {
|
|
32
|
-
return this.
|
|
66
|
+
return !this._error && this.copyEnabled ? e`<calcite-action id=action-copy icon=copy-to-clipboard scale=s @click=${async () => {
|
|
33
67
|
try {
|
|
34
|
-
this.
|
|
35
|
-
} catch (
|
|
36
|
-
console.error("Failed to copy text to clipboard:",
|
|
68
|
+
this._content && await navigator.clipboard.writeText(this._content);
|
|
69
|
+
} catch (t) {
|
|
70
|
+
console.error("Failed to copy text to clipboard:", t);
|
|
37
71
|
}
|
|
38
|
-
}} text></calcite-action><calcite-tooltip reference-element=action-copy overlay-positioning=fixed placement=bottom><span>${this._messages.copyButtonLabel}</span></calcite-tooltip
|
|
72
|
+
}} text></calcite-action><calcite-tooltip reference-element=action-copy overlay-positioning=fixed placement=bottom><span>${this._messages.copyButtonLabel}</span></calcite-tooltip>` : null;
|
|
39
73
|
}
|
|
40
74
|
_renderLogButton() {
|
|
41
|
-
return this.
|
|
75
|
+
return this._log && this.logEnabled ? e`<calcite-action id=action-log icon=access-string-results scale=s @click=${() => this._showLog = !this._showLog} .text=${this._messages.logButtonLabel} .active=${this._showLog}></calcite-action><calcite-tooltip reference-element=action-log overlay-positioning=fixed placement=bottom><span>${this._messages.logButtonLabel}</span></calcite-tooltip>` : null;
|
|
42
76
|
}
|
|
43
77
|
_renderFooter() {
|
|
44
|
-
return this.loading ? null :
|
|
78
|
+
return this.loading ? null : e`<div class="assistant-chat-card__footer"><div class="assistant-chat-card__footer-start">${this._renderCopyButton()}${this._renderLogButton()}<slot name=footer-actions-start></slot></div><div class="assistant-chat-card__footer-end"><slot name=footer-actions-end></slot>${this._renderFeedback()}</div></div>`;
|
|
45
79
|
}
|
|
46
80
|
render() {
|
|
47
|
-
return this.
|
|
81
|
+
return this._role === "user" ? e`<div class="assistant-chat-card__prompt-container"><div>${this._content}</div><div class="assistant-chat-card__prompt-avatar"><calcite-avatar .fullName=${this.user} scale=s></calcite-avatar></div></div>` : e`<div class="assistant-chat-card__response-container"><calcite-icon icon=effects class="assistant-chat-card__response-icon" scale=s></calcite-icon><div class="assistant-chat-card__content-container"><arcgis-assistant-chat-card-content .loading=${this.loading} .loadingMessage=${this.loadingMessage} .type=${this._error ? "error" : "text"} .content=${this._error ?? this._content}></arcgis-assistant-chat-card-content>${this._renderLog()}${this._renderFooter()}</div><div ${d(this._endRef)}></div></div>`;
|
|
48
82
|
}
|
|
49
83
|
}
|
|
50
|
-
|
|
84
|
+
s("arcgis-assistant-chat-card", _);
|
|
51
85
|
export {
|
|
52
|
-
|
|
86
|
+
_ as ArcgisAssistantChatCard
|
|
53
87
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "@esri/calcite-components/components/calcite-accordion";
|
|
2
|
+
import "@esri/calcite-components/components/calcite-accordion-item";
|
|
1
3
|
import "@esri/calcite-components/components/calcite-action";
|
|
2
4
|
import "@esri/calcite-components/components/calcite-tooltip";
|
|
3
5
|
import "@esri/calcite-components/components/calcite-avatar";
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
4
|
-
import { LitElement as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { c as s } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as c, html as t } from "lit";
|
|
4
|
+
import { LitElement as i, safeClassMap as a } from "@arcgis/lumina";
|
|
5
|
+
import { unsafeHTML as r } from "lit/directives/unsafe-html.js";
|
|
6
|
+
import { p as o } from "../../chunks/converterUtils.js";
|
|
7
|
+
const l = c`.assistant-chat-card-content__skeleton-block{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);width:100%}.assistant-chat-card-content__skeleton-text{display:block;height:.95em;border-radius:var(--calcite-border-radius);background:linear-gradient(90deg,color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent),color-mix(in srgb,var(--calcite-color-foreground-3) 85%,transparent),color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent));background-size:200% 100%;animation:assistant-chat-card-content-shimmer 1.2s ease-in-out infinite;width:85%}.assistant-chat-card-content__skeleton-text:last-child{width:70%}@keyframes assistant-chat-card-content-shimmer{0%{background-position:-150% 0}to{background-position:150% 0}}@media(prefers-reduced-motion){.assistant-chat-card-content__skeleton-text{animation:none}}.assistant-chat-card-content__text-container{padding:0 var(--calcite-spacing-sm);display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);color:var(--calcite-color-text-1)}.assistant-chat-card-content__text-container pre{background-color:var(--calcite-color-foreground-1);padding:var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);color:var(--calcite-color-text-1);direction:ltr;max-width:100%;overflow:auto}.assistant-chat-card-content__text-container pre code{display:block;white-space:pre;font-family:var(--calcite-code-family)}.assistant-chat-card-content__loading-container{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm)}.assistant-chat-card-content__loading{display:flex;align-items:center;gap:var(--calcite-spacing-sm)}.assistant-chat-card-content__text-loading{font-style:italic;word-wrap:break-word;word-break:break-all;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:1;line-clamp:1;-webkit-box-orient:vertical}.assistant-chat-card-content__error-notice{padding:var(--calcite-spacing-sm)}`, n = "assistant-chat-card-content", e = {
|
|
8
|
+
textLoading: `${n}__text-loading`,
|
|
9
|
+
skeletonBlock: `${n}__skeleton-block`,
|
|
10
|
+
skeletonText: `${n}__skeleton-text`
|
|
9
11
|
};
|
|
10
|
-
class
|
|
12
|
+
class d extends i {
|
|
11
13
|
constructor() {
|
|
12
14
|
super(...arguments), this.loading = !1, this.type = "text";
|
|
13
15
|
}
|
|
@@ -15,10 +17,10 @@ class c extends o {
|
|
|
15
17
|
this.properties = { loading: 5, type: 1, content: 1, loadingMessage: 1 };
|
|
16
18
|
}
|
|
17
19
|
static {
|
|
18
|
-
this.styles =
|
|
20
|
+
this.styles = l;
|
|
19
21
|
}
|
|
20
22
|
_renderText() {
|
|
21
|
-
return t`<div class="assistant-chat-card-content__text-container"><div><
|
|
23
|
+
return t`<div class="assistant-chat-card-content__text-container">${this.loading ? t`<div class="assistant-chat-card-content__loading-container"><div class="assistant-chat-card-content__loading"><calcite-loader label=loading inline></calcite-loader><div class=${a(e.textLoading)}>${this.loadingMessage}</div></div><div class=${a(e.skeletonBlock)}><span class=${a(e.skeletonText)}></span><span class=${a(e.skeletonText)}></span></div></div>` : t`<div>${r(o(this.content))}</div>`}</div>`;
|
|
22
24
|
}
|
|
23
25
|
_renderError() {
|
|
24
26
|
return t`<calcite-notice class="assistant-chat-card-content__error-notice" open icon kind=warning width=auto><div slot=message>${this.content}</div></calcite-notice>`;
|
|
@@ -34,7 +36,7 @@ class c extends o {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
s("arcgis-assistant-chat-card-content", d);
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
d as ArcgisAssistantChatCardContent
|
|
40
42
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
|
+
import type Collection from "@arcgis/core/core/Collection.js";
|
|
2
3
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
4
|
+
import type { ChatMessage } from "../arcgis-assistant/types.js";
|
|
3
5
|
import type { T9nMeta } from "@arcgis/lumina/controllers";
|
|
4
6
|
|
|
5
7
|
/** @internal */
|
|
@@ -16,11 +18,12 @@ export abstract class ArcgisAssistantChatEntry extends LitElement {
|
|
|
16
18
|
}>;
|
|
17
19
|
/** @default false */
|
|
18
20
|
accessor awaitingResponse: boolean;
|
|
19
|
-
/** @default true */
|
|
20
|
-
accessor enterKeySubmits: boolean;
|
|
21
21
|
accessor entryPlaceholder: string | undefined;
|
|
22
22
|
/** @default "" */
|
|
23
23
|
accessor inputValue: string;
|
|
24
|
+
/** @default false */
|
|
25
|
+
accessor keyboardShortcutsDisabled: boolean;
|
|
26
|
+
accessor messages: Collection<ChatMessage>;
|
|
24
27
|
accessor status: "error" | "ready" | "working" | undefined;
|
|
25
28
|
readonly arcgisCancel: import("@arcgis/lumina").TargetedEvent<this, void>;
|
|
26
29
|
readonly arcgisSubmit: import("@arcgis/lumina").TargetedEvent<this, string>;
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
4
|
-
import { LitElement as
|
|
5
|
-
import { createRef as
|
|
6
|
-
import { watch as
|
|
7
|
-
import { u } from "../../chunks/useT9n.js";
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { c as u } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as h, html as l } from "lit";
|
|
4
|
+
import { LitElement as d, createEvent as c, nothing as p } from "@arcgis/lumina";
|
|
5
|
+
import { createRef as f, ref as g } from "lit/directives/ref.js";
|
|
6
|
+
import { watch as m } from "@arcgis/core/core/reactiveUtils.js";
|
|
7
|
+
import { u as y } from "../../chunks/useT9n.js";
|
|
8
|
+
import _ from "@arcgis/core/core/Collection.js";
|
|
9
|
+
const v = h`.assistant-chat-entry__input-container{display:flex;flex-direction:column}.assistant-chat-entry__footer-start{display:flex;gap:var(--calcite-spacing-md);flex-wrap:wrap;align-items:center}.assistant-chat-entry__footer-end{display:flex;gap:var(--calcite-spacing-md);align-items:center}.assistant-chat-entry__status-indicator{width:9px;height:9px;border-radius:100%;background-color:var(--calcite-color-status-success)}.assistant-chat-entry__status-indicator[data-status=working]{background-color:var(--calcite-color-status-warning)}.assistant-chat-entry__status-indicator[data-status=error]{background-color:var(--calcite-color-status-danger)}.assistant-chat-entry__status-text{text-transform:capitalize}`;
|
|
10
|
+
class w extends d {
|
|
10
11
|
constructor() {
|
|
11
|
-
super(...arguments), this.#
|
|
12
|
+
super(...arguments), this.#s = f(), this.#t = -1, this.#e = "", this._messages = y({ blocking: !0 }), this.keyboardShortcutsDisabled = !1, this.awaitingResponse = !1, this.inputValue = "", this.messages = new _([]), this.arcgisCancel = c(), this.arcgisSubmit = c();
|
|
12
13
|
}
|
|
13
14
|
static {
|
|
14
|
-
this.properties = {
|
|
15
|
+
this.properties = { _userMessages: 16, keyboardShortcutsDisabled: 5, entryPlaceholder: 1, awaitingResponse: 5, inputValue: 1, status: 1, messages: 0 };
|
|
15
16
|
}
|
|
16
17
|
static {
|
|
17
|
-
this.styles =
|
|
18
|
+
this.styles = v;
|
|
18
19
|
}
|
|
20
|
+
#s;
|
|
19
21
|
#t;
|
|
22
|
+
#e;
|
|
23
|
+
get _userMessages() {
|
|
24
|
+
return this.messages.toArray().filter((t) => t.role === "user").map(({ content: t }) => t);
|
|
25
|
+
}
|
|
20
26
|
loaded() {
|
|
21
27
|
this.manager.onLifecycle(() => [
|
|
22
|
-
|
|
23
|
-
this.#
|
|
28
|
+
m(() => this.inputValue, (t) => {
|
|
29
|
+
this.#s.value && (this.#s.value.value = t);
|
|
24
30
|
}, { initial: !0 })
|
|
25
31
|
]);
|
|
26
32
|
}
|
|
@@ -29,16 +35,32 @@ class d extends r {
|
|
|
29
35
|
this.arcgisCancel.emit();
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
32
|
-
const t = this.#
|
|
33
|
-
t && (this.arcgisSubmit.emit(t), this.#t.value && (this.#
|
|
38
|
+
const t = this.#s.value?.value.trim();
|
|
39
|
+
t && (this.arcgisSubmit.emit(t), this.#t = -1, this.#e = "", this.#s.value && (this.#s.value.value = "", await this.#s.value.setFocus()));
|
|
40
|
+
}
|
|
41
|
+
async _navigateHistory(t, i) {
|
|
42
|
+
const s = this.#s.value;
|
|
43
|
+
if (!s)
|
|
44
|
+
return;
|
|
45
|
+
const e = this._userMessages;
|
|
46
|
+
if (e.length === 0)
|
|
47
|
+
return;
|
|
48
|
+
const r = s.value ?? "", n = s.shadowRoot?.querySelector("textarea"), a = n?.selectionStart, o = n?.selectionEnd;
|
|
49
|
+
if (!(a == null || o == null) && !(a !== o || t === "up" && a !== 0 || t === "down" && a !== r.length)) {
|
|
50
|
+
if (t === "up") {
|
|
51
|
+
this.#t === -1 ? (this.#e = r, this.#t = e.length - 1) : this.#t = Math.max(0, this.#t - 1), s.value = e[this.#t] ?? "", i.preventDefault();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.#t !== -1 && (this.#t < e.length - 1 ? (this.#t += 1, s.value = e[this.#t] ?? "") : (this.#t = -1, s.value = this.#e), i.preventDefault());
|
|
55
|
+
}
|
|
34
56
|
}
|
|
35
57
|
render() {
|
|
36
|
-
return
|
|
37
|
-
t.
|
|
38
|
-
}} ${
|
|
58
|
+
return l`<div class="assistant-chat-entry__input-container"><calcite-text-area .value=${this.#s.value?.value} .placeholder=${this.entryPlaceholder ?? this._messages.entryPlaceholder} resize=vertical @keydown=${async (t) => {
|
|
59
|
+
t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || this.keyboardShortcutsDisabled || (t.key === "Enter" ? (t.preventDefault(), await this._submitMessage()) : t.key === "ArrowUp" ? await this._navigateHistory("up", t) : t.key === "ArrowDown" && await this._navigateHistory("down", t));
|
|
60
|
+
}} ${g(this.#s)}><div slot=footer-start class="assistant-chat-entry__footer-start"><slot name=entry-actions-start></slot></div><div slot=footer-end class="assistant-chat-entry__footer-end">${this.status ? l`<div id=tooltip-status class="assistant-chat-entry__status-indicator" data-status=${this.status ?? p}></div><calcite-tooltip reference-element=tooltip-status offset-distance=12><span class="assistant-chat-entry__status-text">${this.status}</span></calcite-tooltip>` : null}<calcite-button .iconStart=${this.awaitingResponse ? "circle-stop" : "send"} slot=footer-end round @click=${() => void this._submitMessage()}>${this.awaitingResponse ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></div></calcite-text-area></div>`;
|
|
39
61
|
}
|
|
40
62
|
}
|
|
41
|
-
|
|
63
|
+
u("arcgis-assistant-chat-entry", w);
|
|
42
64
|
export {
|
|
43
|
-
|
|
65
|
+
w as ArcgisAssistantChatEntry
|
|
44
66
|
};
|
|
@@ -3,14 +3,23 @@ import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
|
3
3
|
import type { ArcgisMap as ArcgisMap } from "@arcgis/map-components/components/arcgis-map";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* The Data Exploration Agent
|
|
7
|
-
*
|
|
8
|
-
* a 2D web map.
|
|
6
|
+
* The Data Exploration Agent enables the end user to query features, statistics, and spatial proximity
|
|
7
|
+
* to features in a layer within a web map. Currently, this is only scoped to querying feature layers within
|
|
8
|
+
* a 2D web map. See the list of capabilities below for more details.
|
|
9
|
+
*
|
|
10
|
+
* The data exploration agent is designed to answer questions about the data in the map, and does not have
|
|
11
|
+
* access to external data sources or the user's location. It also cannot create visualizations in the form of charts,
|
|
12
|
+
* layer renderers, new maps, or other visual outputs. It can currently only provide answers in text form based on the
|
|
13
|
+
* data in the map.
|
|
14
|
+
*
|
|
15
|
+
* This agent can change the state of the map by filtering features in a layer, but it cannot change the symbology of
|
|
16
|
+
* features or create new layers or export results of a query to a file or external source.
|
|
9
17
|
*
|
|
10
18
|
* This is an unrendered component that must be added as a child of the `arcgis-assistant` component in either HTML or JavaScript.
|
|
11
19
|
*
|
|
12
20
|
* ```html
|
|
13
|
-
* <arcgis-
|
|
21
|
+
* <arcgis-map id="my-map"></arcgis-map>
|
|
22
|
+
* <arcgis-assistant reference-element="my-map">
|
|
14
23
|
* <arcgis-assistant-data-exploration-agent></arcgis-assistant-data-exploration-agent>
|
|
15
24
|
* </arcgis-assistant>
|
|
16
25
|
* ```
|
|
@@ -21,14 +30,72 @@ import type { ArcgisMap as ArcgisMap } from "@arcgis/map-components/components/a
|
|
|
21
30
|
* assistant.appendChild(dataExplorationAgent);
|
|
22
31
|
* ```
|
|
23
32
|
*
|
|
33
|
+
* Once added to the assistant, the agent is loaded and ready to receive user messages related to data exploration.
|
|
34
|
+
*
|
|
35
|
+
* ### Capabilities
|
|
36
|
+
*
|
|
37
|
+
* The data exploration agent provides the following capabilities related to exploring data in the map:
|
|
38
|
+
*
|
|
39
|
+
* - **Query features** - Ask about the attributes of features in a layer, including a single feature or a set
|
|
40
|
+
* of features.
|
|
41
|
+
* - **Query statistics** - Ask about statistics related to features in a layer. Statistics that can be queried
|
|
42
|
+
* include count, average, minimum, maximum, and sum. This includes asking about the top number of features based on a
|
|
43
|
+
* particular attribute.
|
|
44
|
+
* - **Query spatial proximity** - Ask about the spatial proximity of features in a layer, such as
|
|
45
|
+
* the number of features that intersect a polygon, or information about features within a distance of a specified location or feature.
|
|
46
|
+
* This currently does not include questions about the closest feature, but this is planned to be included in a future release.
|
|
47
|
+
* - **Filter features** - Users can ask the agent to show a subset of features that filter by attributes, or spatial
|
|
48
|
+
* proximity to other features. This includes asking the agent to show features that intersect a particular area,
|
|
49
|
+
* or are within a certain distance of a location or feature.
|
|
50
|
+
*
|
|
51
|
+
* ### Example questions
|
|
52
|
+
*
|
|
53
|
+
* The following are example questions a user can ask within the bounds of the data exploration agent.
|
|
54
|
+
* These questions assume a map with layers that include cities, states, and rivers.
|
|
55
|
+
*
|
|
56
|
+
* - "What is the city with the largest population?"
|
|
57
|
+
* - "How does that population compare to the average population of the cities in this map?"
|
|
58
|
+
* - "How many cities are within 30 miles of the Colorado River?"
|
|
59
|
+
* - "Show all cities in the state of California."
|
|
60
|
+
* - "List the top 5 rivers by length."
|
|
61
|
+
* - "Emphasize the largest river on the map."
|
|
62
|
+
*
|
|
63
|
+
* The following are examples of the types of questions that fall outside the bounds of the
|
|
64
|
+
* data exploration agent and should therefore be avoided:
|
|
65
|
+
*
|
|
66
|
+
* - "What is the closest restaurant to me?" (the data exploration agent does not have access to the user's location,
|
|
67
|
+
* nor can it find the nearest feature from a location)
|
|
68
|
+
* - "What is the projected growth of Phoenix in the next 10 years?" (the data exploration agent can
|
|
69
|
+
* only answer questions about the data in the map, not external data or projections)
|
|
70
|
+
* - "Show me the population of cities in this map on a graph." (the data exploration agent can only
|
|
71
|
+
* provide answers in text form, not visualizations)
|
|
72
|
+
*
|
|
73
|
+
* > Due to the non-deterministic nature of generative AI, there may be inaccuracies or unexpected behavior when using the
|
|
74
|
+
* out-of-the-box agents.
|
|
75
|
+
*
|
|
24
76
|
* @since 5.0
|
|
25
77
|
* @beta
|
|
26
78
|
* @see [arcgis-assistant](https://developers.arcgis.com/javascript/latest/references/ai-components/components/arcgis-assistant/)
|
|
79
|
+
* @see [Intro to building agentic mapping applications](https://developers.arcgis.com/javascript/latest/agentic-apps/ai-introduction/)
|
|
80
|
+
* @see [AI Assistant component sample](https://developers.arcgis.com/javascript/latest/sample-code/ai-assistant/)
|
|
27
81
|
*/
|
|
28
82
|
export abstract class ArcgisAssistantDataExplorationAgent extends LitElement {
|
|
29
83
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
84
|
+
* The reference element to the map that provides context for the data exploration agent. Currently,
|
|
85
|
+
* this is only scoped to `arcgis-map` elements. This provides the data exploration agent with the layers
|
|
86
|
+
* needed for answering user questions about the data in the map.
|
|
87
|
+
*
|
|
88
|
+
* Setting this property is not necessary if you set the reference element on the parent
|
|
89
|
+
* `arcgis-assistant` component.
|
|
90
|
+
*
|
|
91
|
+
* @see [arcgis-assistant.referenceElement](https://developers.arcgis.com/javascript/latest/references/ai-components/components/arcgis-assistant/#referenceElement)
|
|
92
|
+
* @example
|
|
93
|
+
* ```html
|
|
94
|
+
* <arcgis-map id="my-map"></arcgis-map>
|
|
95
|
+
* <arcgis-assistant>
|
|
96
|
+
* <arcgis-assistant-data-exploration-agent reference-element="my-map"></arcgis-assistant-data-exploration-agent>
|
|
97
|
+
* </arcgis-assistant>
|
|
98
|
+
* ```
|
|
32
99
|
*/
|
|
33
100
|
accessor referenceElement: ArcgisMap | string | undefined;
|
|
34
101
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import { c as t } from "../../chunks/runtime.js";
|
|
3
3
|
import { LitElement as a } from "@arcgis/lumina";
|
|
4
|
-
import { DataExplorationAgent as
|
|
5
|
-
import { r as
|
|
4
|
+
import { DataExplorationAgent as e } from "@arcgis/ai-agents";
|
|
5
|
+
import { r as s, a as i } from "../../chunks/utils.js";
|
|
6
6
|
class r extends a {
|
|
7
7
|
constructor() {
|
|
8
|
-
super(...arguments), this.agent =
|
|
8
|
+
super(...arguments), this.agent = e;
|
|
9
9
|
}
|
|
10
10
|
static {
|
|
11
11
|
this.properties = { referenceElement: 1 };
|
|
@@ -16,8 +16,8 @@ class r extends a {
|
|
|
16
16
|
throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");
|
|
17
17
|
return { mapView: this.#t };
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
this.#t =
|
|
19
|
+
load() {
|
|
20
|
+
this.#t = s(this, "arcgis-assistant-data-exploration-agent"), i(this);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
t("arcgis-assistant-data-exploration-agent", r);
|