aov-agent 1.0.9 → 1.0.11
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-ui/components/Assistant/AssistantWidget/AssistantWidget.js +32 -4
- package/dist/agent-ui/components/Assistant/AssistantWidget/AssistantWidget.scss +29 -0
- package/dist/agent-ui/components/Assistant/ThreadProvider.js +0 -7
- package/dist/agent-ui/components/Assistant/ToolResult/CardTool.js +18 -0
- package/package.json +3 -2
|
@@ -13,6 +13,7 @@ import PropTypes from "prop-types";
|
|
|
13
13
|
import { Badge, BlockStack, Box, Button, InlineStack, Popover, Spinner, Text } from "@shopify/polaris";
|
|
14
14
|
import { ComposeIcon, XIcon } from "@shopify/polaris-icons";
|
|
15
15
|
import { ThreadContext } from "../../../contexts/ThreadContext.js";
|
|
16
|
+
import { useThread, useMessage } from "@assistant-ui/react";
|
|
16
17
|
import { Composer, Thread, ThreadWelcome } from "@assistant-ui/react-ui";
|
|
17
18
|
import { MarkdownText } from "../Markdown/MarkdownText.js";
|
|
18
19
|
import MathRenderer from "../Markdown/MathRenderer.js";
|
|
@@ -25,6 +26,7 @@ import "./AssistantWidget.scss";
|
|
|
25
26
|
import Avatar from "../../../resources/assistant-avatar.svg";
|
|
26
27
|
import { welcomeSuggestions, welComeMessage } from "../../../const/option";
|
|
27
28
|
import { AgentContext } from "../../../contexts/AgentContext.js";
|
|
29
|
+
import { ContactSupportCard } from "../ToolResult/CardTool.js";
|
|
28
30
|
var AssistantText = /*#__PURE__*/React.memo(function AssistantText(props) {
|
|
29
31
|
try {
|
|
30
32
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -49,6 +51,31 @@ var AssistantTool = /*#__PURE__*/React.memo(function AssistantTool(_ref) {
|
|
|
49
51
|
return null;
|
|
50
52
|
}
|
|
51
53
|
});
|
|
54
|
+
var AssistantMessageFooter = function AssistantMessageFooter() {
|
|
55
|
+
var messages = useThread(function (state) {
|
|
56
|
+
return state.messages;
|
|
57
|
+
});
|
|
58
|
+
var currentMessage = useMessage();
|
|
59
|
+
var isRunning = useThread(function (state) {
|
|
60
|
+
return state.isRunning;
|
|
61
|
+
});
|
|
62
|
+
if (isRunning) return null;
|
|
63
|
+
var currentIndex = messages.findIndex(function (m) {
|
|
64
|
+
return m.id === currentMessage.id;
|
|
65
|
+
});
|
|
66
|
+
var userMessage = messages.slice(0, currentIndex).reverse().find(function (m) {
|
|
67
|
+
return m.role === "user";
|
|
68
|
+
});
|
|
69
|
+
if (!userMessage) return null;
|
|
70
|
+
var userContent = Array.isArray(userMessage.content) ? userMessage.content.filter(function (part) {
|
|
71
|
+
return part.type === "text";
|
|
72
|
+
}).map(function (part) {
|
|
73
|
+
return part.text;
|
|
74
|
+
}).join(" ") : userMessage.content;
|
|
75
|
+
return /*#__PURE__*/React.createElement(ContactSupportCard, {
|
|
76
|
+
userContent: userContent
|
|
77
|
+
});
|
|
78
|
+
};
|
|
52
79
|
var AssistantWidget = function AssistantWidget(_ref2) {
|
|
53
80
|
var onClose = _ref2.onClose;
|
|
54
81
|
var _useContext = useContext(AgentContext),
|
|
@@ -95,7 +122,8 @@ var AssistantWidget = function AssistantWidget(_ref2) {
|
|
|
95
122
|
return /*#__PURE__*/React.createElement(AssistantTool, _extends({
|
|
96
123
|
shop: shop
|
|
97
124
|
}, props));
|
|
98
|
-
}
|
|
125
|
+
},
|
|
126
|
+
Footer: AssistantMessageFooter
|
|
99
127
|
};
|
|
100
128
|
}, [shop]);
|
|
101
129
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -114,8 +142,8 @@ var AssistantWidget = function AssistantWidget(_ref2) {
|
|
|
114
142
|
wrap: false
|
|
115
143
|
}, loadingThreads && !(thread !== null && thread !== void 0 && thread.title) ? /*#__PURE__*/React.createElement(Spinner, {
|
|
116
144
|
size: "small"
|
|
117
|
-
}) : /*#__PURE__*/React.createElement(
|
|
118
|
-
|
|
145
|
+
}) : /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: "AOV-Sidekick__ChatSelector"
|
|
119
147
|
}, /*#__PURE__*/React.createElement(Popover, {
|
|
120
148
|
active: popoverActive,
|
|
121
149
|
activator: activator,
|
|
@@ -134,7 +162,7 @@ var AssistantWidget = function AssistantWidget(_ref2) {
|
|
|
134
162
|
updateThread: updateThread,
|
|
135
163
|
deleteThread: deleteThread
|
|
136
164
|
}))), /*#__PURE__*/React.createElement(Box, {
|
|
137
|
-
|
|
165
|
+
width: "90px"
|
|
138
166
|
}, /*#__PURE__*/React.createElement(InlineStack, {
|
|
139
167
|
wrap: false,
|
|
140
168
|
blockAlign: "center",
|
|
@@ -16,6 +16,20 @@
|
|
|
16
16
|
height: 100%;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.AOV-Sidekick__ChatSelector{
|
|
20
|
+
width: calc(100% - 100px);
|
|
21
|
+
.Polaris-Box, button {
|
|
22
|
+
width: 100% !important;
|
|
23
|
+
justify-content: left;
|
|
24
|
+
> span {
|
|
25
|
+
max-width: 100%;
|
|
26
|
+
}
|
|
27
|
+
.Polaris-Icon{
|
|
28
|
+
margin: unset;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
.aui-thread-root {
|
|
20
34
|
height: 100%;
|
|
21
35
|
font-family: Arial, Helvetica, sans-serif;
|
|
@@ -116,6 +130,21 @@
|
|
|
116
130
|
display: flex;
|
|
117
131
|
align-items: center;
|
|
118
132
|
}
|
|
133
|
+
.assistant-message-footer {
|
|
134
|
+
width: 100%;
|
|
135
|
+
margin-top: 8px;
|
|
136
|
+
margin-left: 38px;
|
|
137
|
+
button {
|
|
138
|
+
font-size: 12px;
|
|
139
|
+
padding: 4px 10px;
|
|
140
|
+
border-radius: 6px;
|
|
141
|
+
border: 1px solid #e0e0e0;
|
|
142
|
+
background-color: #fafafa;
|
|
143
|
+
&:hover {
|
|
144
|
+
background-color: #f0f0f0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
119
148
|
}
|
|
120
149
|
img {
|
|
121
150
|
display: block;
|
|
@@ -178,7 +178,6 @@ var createStreamingModelAdapter = function createStreamingModelAdapter(_ref) {
|
|
|
178
178
|
_context.n = 8;
|
|
179
179
|
return _awaitAsyncGenerator(streamPromise);
|
|
180
180
|
case 8:
|
|
181
|
-
// Call onComplete with final messages after stream ends
|
|
182
181
|
if (onComplete) {
|
|
183
182
|
userMessage = messages.findLast(function (m) {
|
|
184
183
|
return m.role === "user";
|
|
@@ -265,8 +264,6 @@ var ThreadProvider = function ThreadProvider(_ref3) {
|
|
|
265
264
|
var clearSession = useCallback(function () {
|
|
266
265
|
clearThreadSession(appName);
|
|
267
266
|
}, [appName]);
|
|
268
|
-
|
|
269
|
-
// Validate cached thread still exists after threads are fetched
|
|
270
267
|
useEffect(function () {
|
|
271
268
|
var _cachedSession$thread;
|
|
272
269
|
if (!threadsFetched || sessionValidatedRef.current) return;
|
|
@@ -279,7 +276,6 @@ var ThreadProvider = function ThreadProvider(_ref3) {
|
|
|
279
276
|
});
|
|
280
277
|
});
|
|
281
278
|
if (!threadExists) {
|
|
282
|
-
// Thread no longer exists, clear everything
|
|
283
279
|
setThread({});
|
|
284
280
|
clearSession();
|
|
285
281
|
}
|
|
@@ -328,8 +324,6 @@ var ThreadProvider = function ThreadProvider(_ref3) {
|
|
|
328
324
|
});
|
|
329
325
|
}, [onSuggestions, stream, thread, onStart, onComplete, clearSuggestions, shop]);
|
|
330
326
|
var runtime = useLocalRuntime(modelAdapter);
|
|
331
|
-
|
|
332
|
-
// Initialize runtime with cached messages on mount
|
|
333
327
|
var initializedRef = useRef(false);
|
|
334
328
|
useEffect(function () {
|
|
335
329
|
if (initializedRef.current || !runtime) return;
|
|
@@ -369,7 +363,6 @@ var ThreadProvider = function ThreadProvider(_ref3) {
|
|
|
369
363
|
runtime.reset({
|
|
370
364
|
initialMessages: messages
|
|
371
365
|
});
|
|
372
|
-
// Save thread and messages to session
|
|
373
366
|
if (threadData) {
|
|
374
367
|
setThread(threadData);
|
|
375
368
|
saveSession(threadData, messages);
|
|
@@ -5,6 +5,7 @@ import { oneLight } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
|
5
5
|
import CopyToClipboard from "../../CopyToClipboard/CopyToClipboard";
|
|
6
6
|
import { formatQuery } from "../../../helpers/formatQuery";
|
|
7
7
|
import "./CardTool.scss";
|
|
8
|
+
import { ChatIcon } from "@shopify/polaris-icons";
|
|
8
9
|
export var TalkToHumanCard = function TalkToHumanCard(_ref) {
|
|
9
10
|
var result = _ref.result;
|
|
10
11
|
if (!result) return null;
|
|
@@ -95,4 +96,21 @@ export var GetShopifyDataCard = function GetShopifyDataCard(_ref3) {
|
|
|
95
96
|
alignment: "center"
|
|
96
97
|
}, item.name);
|
|
97
98
|
}) : "There was no data found for this date range."))))));
|
|
99
|
+
};
|
|
100
|
+
export var ContactSupportCard = function ContactSupportCard(_ref5) {
|
|
101
|
+
var userContent = _ref5.userContent;
|
|
102
|
+
var handleContactSupport = function handleContactSupport() {
|
|
103
|
+
if (window.$crisp) {
|
|
104
|
+
var message = "\uD83D\uDCAC This message has been forwarded to Human Support from the AI Assistant.\n\n ----------------------------------------\n ".concat(userContent);
|
|
105
|
+
window.$crisp.push(["do", "chat:open"]);
|
|
106
|
+
window.$crisp.push(["do", "message:send", ["text", message]]);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
110
|
+
onClick: handleContactSupport,
|
|
111
|
+
variant: "secondary",
|
|
112
|
+
size: "slim",
|
|
113
|
+
fullWidth: true,
|
|
114
|
+
icon: ChatIcon
|
|
115
|
+
}, "Contact Human Support");
|
|
98
116
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aov-agent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "AOV AI Agent - Monorepo for AI Assistant Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"katex": "^0.16.22",
|
|
74
74
|
"prop-types": "^15.8.1",
|
|
75
75
|
"query-string": "^7.1.3",
|
|
76
|
-
"react-syntax-highlighter": "^15.6.6"
|
|
76
|
+
"react-syntax-highlighter": "^15.6.6",
|
|
77
|
+
"remark-gfm": "^4.0.1"
|
|
77
78
|
}
|
|
78
79
|
}
|