llmasaservice-ui 0.7.9 → 0.7.10
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/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +41 -39
- package/dist/index.mjs +41 -39
- package/package.json +1 -1
- package/src/AgentPanel.tsx +20 -28
- package/src/ChatPanel.tsx +12 -0
- package/src/stories/AgentPanel.stories.ts +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -21,6 +21,7 @@ interface ChatPanelProps {
|
|
|
21
21
|
thumbsUpClick?: (callId: string) => void;
|
|
22
22
|
thumbsDownClick?: (callId: string) => void;
|
|
23
23
|
theme?: "light" | "dark";
|
|
24
|
+
cssUrl?: string;
|
|
24
25
|
markdownClass?: string;
|
|
25
26
|
width?: string;
|
|
26
27
|
height?: string;
|
|
@@ -65,7 +66,6 @@ interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
|
|
|
65
66
|
declare const ChatPanel: React.FC<ChatPanelProps & ExtraProps$1>;
|
|
66
67
|
|
|
67
68
|
interface AgentPanelProps {
|
|
68
|
-
project_id: string;
|
|
69
69
|
customer?: LLMAsAServiceCustomer;
|
|
70
70
|
messages?: {
|
|
71
71
|
role: "user" | "assistant";
|
|
@@ -77,6 +77,9 @@ interface AgentPanelProps {
|
|
|
77
77
|
}[];
|
|
78
78
|
thumbsUpClick?: (callId: string) => void;
|
|
79
79
|
thumbsDownClick?: (callId: string) => void;
|
|
80
|
+
theme?: "light" | "dark";
|
|
81
|
+
width?: string;
|
|
82
|
+
height?: string;
|
|
80
83
|
url?: string;
|
|
81
84
|
prismStyle?: PrismStyle;
|
|
82
85
|
service?: string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ interface ChatPanelProps {
|
|
|
21
21
|
thumbsUpClick?: (callId: string) => void;
|
|
22
22
|
thumbsDownClick?: (callId: string) => void;
|
|
23
23
|
theme?: "light" | "dark";
|
|
24
|
+
cssUrl?: string;
|
|
24
25
|
markdownClass?: string;
|
|
25
26
|
width?: string;
|
|
26
27
|
height?: string;
|
|
@@ -65,7 +66,6 @@ interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
|
|
|
65
66
|
declare const ChatPanel: React.FC<ChatPanelProps & ExtraProps$1>;
|
|
66
67
|
|
|
67
68
|
interface AgentPanelProps {
|
|
68
|
-
project_id: string;
|
|
69
69
|
customer?: LLMAsAServiceCustomer;
|
|
70
70
|
messages?: {
|
|
71
71
|
role: "user" | "assistant";
|
|
@@ -77,6 +77,9 @@ interface AgentPanelProps {
|
|
|
77
77
|
}[];
|
|
78
78
|
thumbsUpClick?: (callId: string) => void;
|
|
79
79
|
thumbsDownClick?: (callId: string) => void;
|
|
80
|
+
theme?: "light" | "dark";
|
|
81
|
+
width?: string;
|
|
82
|
+
height?: string;
|
|
80
83
|
url?: string;
|
|
81
84
|
prismStyle?: PrismStyle;
|
|
82
85
|
service?: string | null;
|
package/dist/index.js
CHANGED
|
@@ -175,6 +175,7 @@ var ChatPanel = ({
|
|
|
175
175
|
thumbsUpClick,
|
|
176
176
|
thumbsDownClick,
|
|
177
177
|
theme = "light",
|
|
178
|
+
cssUrl = "",
|
|
178
179
|
markdownClass = null,
|
|
179
180
|
width = "300px",
|
|
180
181
|
height = "100vh",
|
|
@@ -240,6 +241,15 @@ var ChatPanel = ({
|
|
|
240
241
|
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
241
242
|
};
|
|
242
243
|
}, []);
|
|
244
|
+
(0, import_react3.useEffect)(() => {
|
|
245
|
+
if (cssUrl && cssUrl !== "") {
|
|
246
|
+
const link = document.createElement("link");
|
|
247
|
+
link.href = cssUrl;
|
|
248
|
+
link.rel = "stylesheet";
|
|
249
|
+
document.head.appendChild(link);
|
|
250
|
+
console.log("Added css link", link);
|
|
251
|
+
}
|
|
252
|
+
}, [cssUrl]);
|
|
243
253
|
(0, import_react3.useEffect)(() => {
|
|
244
254
|
if (response && response.length > 0) {
|
|
245
255
|
setIsLoading(false);
|
|
@@ -1085,7 +1095,7 @@ var import_react4 = __toESM(require("react"));
|
|
|
1085
1095
|
var import_material_dark2 = __toESM(require("react-syntax-highlighter/dist/esm/styles/prism/material-dark.js"));
|
|
1086
1096
|
var import_material_light2 = __toESM(require("react-syntax-highlighter/dist/esm/styles/prism/material-light.js"));
|
|
1087
1097
|
var AgentPanel = ({
|
|
1088
|
-
project_id,
|
|
1098
|
+
//project_id,
|
|
1089
1099
|
//initialPrompt = "",
|
|
1090
1100
|
//title = "Chat",
|
|
1091
1101
|
//placeholder = "Type a message",
|
|
@@ -1095,16 +1105,16 @@ var AgentPanel = ({
|
|
|
1095
1105
|
data = [],
|
|
1096
1106
|
thumbsUpClick,
|
|
1097
1107
|
thumbsDownClick,
|
|
1098
|
-
|
|
1108
|
+
theme,
|
|
1099
1109
|
//markdownClass = null,
|
|
1100
|
-
|
|
1101
|
-
|
|
1110
|
+
width,
|
|
1111
|
+
height,
|
|
1102
1112
|
url = "https://chat.llmasaservice.io/",
|
|
1103
1113
|
//scrollToEnd = false,
|
|
1104
1114
|
//initialMessage = "",
|
|
1105
1115
|
//prismStyle = theme === "light" ? materialLight : materialDark,
|
|
1106
1116
|
service = null,
|
|
1107
|
-
historyChangedCallback =
|
|
1117
|
+
historyChangedCallback = void 0,
|
|
1108
1118
|
//promptTemplate = "",
|
|
1109
1119
|
actions = [],
|
|
1110
1120
|
//showSaveButton = true,
|
|
@@ -1123,7 +1133,7 @@ var AgentPanel = ({
|
|
|
1123
1133
|
//ragQueryLimit = 10,
|
|
1124
1134
|
//ragRankLimit = 5,
|
|
1125
1135
|
}) => {
|
|
1126
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1136
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1127
1137
|
const [followOnPrompt, setFollowOnPrompt] = (0, import_react4.useState)("");
|
|
1128
1138
|
const searchParams = new URLSearchParams(location.search);
|
|
1129
1139
|
const customer_id = searchParams.get("customer_id") || "";
|
|
@@ -1143,13 +1153,6 @@ var AgentPanel = ({
|
|
|
1143
1153
|
);
|
|
1144
1154
|
const data2 = yield response.json();
|
|
1145
1155
|
if (data2 && data2.length > 0) {
|
|
1146
|
-
if (data2 && data2[0].cssUrl && data2[0].cssUrl !== "") {
|
|
1147
|
-
const link = document.createElement("link");
|
|
1148
|
-
link.rel = "stylesheet";
|
|
1149
|
-
link.href = data2[0].cssUrl;
|
|
1150
|
-
document.head.appendChild(link);
|
|
1151
|
-
console.log("Added css link", link);
|
|
1152
|
-
}
|
|
1153
1156
|
setAgentData(data2[0]);
|
|
1154
1157
|
}
|
|
1155
1158
|
} catch (error) {
|
|
@@ -1181,19 +1184,16 @@ var AgentPanel = ({
|
|
|
1181
1184
|
service: (agentData == null ? void 0 : agentData.groupId) || null,
|
|
1182
1185
|
url,
|
|
1183
1186
|
title: (_a = agentData == null ? void 0 : agentData.displayTitle) != null ? _a : "",
|
|
1184
|
-
theme: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? "light" : "dark",
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1187
|
+
theme: theme ? theme : (agentData == null ? void 0 : agentData.displayTheme) === "light" ? "light" : "dark",
|
|
1188
|
+
cssUrl: (_b = agentData == null ? void 0 : agentData.cssUrl) != null ? _b : "",
|
|
1189
|
+
height: height ? height : (_c = agentData == null ? void 0 : agentData.displayHeight) != null ? _c : "100vh",
|
|
1190
|
+
width: width ? width : (_d = agentData == null ? void 0 : agentData.displayWidth) != null ? _d : "100%",
|
|
1191
|
+
promptTemplate: (_e = agentData == null ? void 0 : agentData.displayPromptTemplate) != null ? _e : "{{prompt}}",
|
|
1192
|
+
initialMessage: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "message" ? (_f = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _f : "" : void 0,
|
|
1193
|
+
initialPrompt: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "prompt" ? (_g = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _g : "" : void 0,
|
|
1194
|
+
followOnQuestions: followOnQuestions ? followOnQuestions : (_i = (_h = agentData == null ? void 0 : agentData.displayFollowOnPrompts) == null ? void 0 : _h.split("|")) != null ? _i : [],
|
|
1191
1195
|
clearFollowOnQuestionsNextPrompt,
|
|
1192
|
-
historyChangedCallback
|
|
1193
|
-
if (history) {
|
|
1194
|
-
setFollowOnPrompt("");
|
|
1195
|
-
}
|
|
1196
|
-
},
|
|
1196
|
+
historyChangedCallback,
|
|
1197
1197
|
prismStyle: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? import_material_light2.default : import_material_dark2.default,
|
|
1198
1198
|
actions: [
|
|
1199
1199
|
...actions,
|
|
@@ -1201,23 +1201,25 @@ var AgentPanel = ({
|
|
|
1201
1201
|
],
|
|
1202
1202
|
followOnPrompt,
|
|
1203
1203
|
agent,
|
|
1204
|
-
placeholder: (
|
|
1205
|
-
hideInitialPrompt: (
|
|
1204
|
+
placeholder: (_j = agentData == null ? void 0 : agentData.displayPlaceholder) != null ? _j : "Type a message",
|
|
1205
|
+
hideInitialPrompt: (_k = agentData == null ? void 0 : agentData.displayHideInitialPrompt) != null ? _k : true,
|
|
1206
1206
|
data: [...data, { key: "data", data: agentData == null ? void 0 : agentData.data }],
|
|
1207
|
-
showEmailButton: (
|
|
1208
|
-
showSaveButton: (
|
|
1209
|
-
showCallToAction: (
|
|
1210
|
-
callToActionButtonText: (
|
|
1211
|
-
callToActionEmailAddress: (
|
|
1212
|
-
callToActionEmailSubject: (
|
|
1213
|
-
callToActionMustSendEmail: (
|
|
1207
|
+
showEmailButton: (_l = agentData == null ? void 0 : agentData.displayShowEmailButton) != null ? _l : true,
|
|
1208
|
+
showSaveButton: (_m = agentData == null ? void 0 : agentData.displayShowSaveButton) != null ? _m : true,
|
|
1209
|
+
showCallToAction: (_n = agentData == null ? void 0 : agentData.displayShowCallToAction) != null ? _n : false,
|
|
1210
|
+
callToActionButtonText: (_o = agentData == null ? void 0 : agentData.displayCallToActionButtonText) != null ? _o : "Submit",
|
|
1211
|
+
callToActionEmailAddress: (_p = agentData == null ? void 0 : agentData.displayCallToActionEmailAddress) != null ? _p : "",
|
|
1212
|
+
callToActionEmailSubject: (_q = agentData == null ? void 0 : agentData.displayCallToActionEmailSubject) != null ? _q : "Agent CTA Submitted",
|
|
1213
|
+
callToActionMustSendEmail: (_r = agentData == null ? void 0 : agentData.displayCallToActionMustSendEmail) != null ? _r : false,
|
|
1214
1214
|
customer: {
|
|
1215
|
-
customer_id: customer_id != null ? customer_id : "
|
|
1216
|
-
customer_user_email: customer_email != null ? customer_email : ""
|
|
1215
|
+
customer_id: customer ? customer.customer_id : customer_id != null ? customer_id : "",
|
|
1216
|
+
customer_user_email: customer ? customer.customer_user_email : customer_email != null ? customer_email : ""
|
|
1217
1217
|
},
|
|
1218
|
-
scrollToEnd: (
|
|
1219
|
-
ragQueryLimit: (
|
|
1220
|
-
ragRankLimit: (
|
|
1218
|
+
scrollToEnd: (_s = agentData == null ? void 0 : agentData.displayScrollToEnd) != null ? _s : false,
|
|
1219
|
+
ragQueryLimit: (_t = agentData == null ? void 0 : agentData.ragQueryLimit) != null ? _t : 10,
|
|
1220
|
+
ragRankLimit: (_u = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _u : 5,
|
|
1221
|
+
showPoweredBy,
|
|
1222
|
+
messages
|
|
1221
1223
|
}
|
|
1222
1224
|
));
|
|
1223
1225
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -141,6 +141,7 @@ var ChatPanel = ({
|
|
|
141
141
|
thumbsUpClick,
|
|
142
142
|
thumbsDownClick,
|
|
143
143
|
theme = "light",
|
|
144
|
+
cssUrl = "",
|
|
144
145
|
markdownClass = null,
|
|
145
146
|
width = "300px",
|
|
146
147
|
height = "100vh",
|
|
@@ -206,6 +207,15 @@ var ChatPanel = ({
|
|
|
206
207
|
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
207
208
|
};
|
|
208
209
|
}, []);
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (cssUrl && cssUrl !== "") {
|
|
212
|
+
const link = document.createElement("link");
|
|
213
|
+
link.href = cssUrl;
|
|
214
|
+
link.rel = "stylesheet";
|
|
215
|
+
document.head.appendChild(link);
|
|
216
|
+
console.log("Added css link", link);
|
|
217
|
+
}
|
|
218
|
+
}, [cssUrl]);
|
|
209
219
|
useEffect(() => {
|
|
210
220
|
if (response && response.length > 0) {
|
|
211
221
|
setIsLoading(false);
|
|
@@ -1051,7 +1061,7 @@ import React4, { useEffect as useEffect2, useState as useState4 } from "react";
|
|
|
1051
1061
|
import materialDark2 from "react-syntax-highlighter/dist/esm/styles/prism/material-dark.js";
|
|
1052
1062
|
import materialLight2 from "react-syntax-highlighter/dist/esm/styles/prism/material-light.js";
|
|
1053
1063
|
var AgentPanel = ({
|
|
1054
|
-
project_id,
|
|
1064
|
+
//project_id,
|
|
1055
1065
|
//initialPrompt = "",
|
|
1056
1066
|
//title = "Chat",
|
|
1057
1067
|
//placeholder = "Type a message",
|
|
@@ -1061,16 +1071,16 @@ var AgentPanel = ({
|
|
|
1061
1071
|
data = [],
|
|
1062
1072
|
thumbsUpClick,
|
|
1063
1073
|
thumbsDownClick,
|
|
1064
|
-
|
|
1074
|
+
theme,
|
|
1065
1075
|
//markdownClass = null,
|
|
1066
|
-
|
|
1067
|
-
|
|
1076
|
+
width,
|
|
1077
|
+
height,
|
|
1068
1078
|
url = "https://chat.llmasaservice.io/",
|
|
1069
1079
|
//scrollToEnd = false,
|
|
1070
1080
|
//initialMessage = "",
|
|
1071
1081
|
//prismStyle = theme === "light" ? materialLight : materialDark,
|
|
1072
1082
|
service = null,
|
|
1073
|
-
historyChangedCallback =
|
|
1083
|
+
historyChangedCallback = void 0,
|
|
1074
1084
|
//promptTemplate = "",
|
|
1075
1085
|
actions = [],
|
|
1076
1086
|
//showSaveButton = true,
|
|
@@ -1089,7 +1099,7 @@ var AgentPanel = ({
|
|
|
1089
1099
|
//ragQueryLimit = 10,
|
|
1090
1100
|
//ragRankLimit = 5,
|
|
1091
1101
|
}) => {
|
|
1092
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1093
1103
|
const [followOnPrompt, setFollowOnPrompt] = useState4("");
|
|
1094
1104
|
const searchParams = new URLSearchParams(location.search);
|
|
1095
1105
|
const customer_id = searchParams.get("customer_id") || "";
|
|
@@ -1109,13 +1119,6 @@ var AgentPanel = ({
|
|
|
1109
1119
|
);
|
|
1110
1120
|
const data2 = yield response.json();
|
|
1111
1121
|
if (data2 && data2.length > 0) {
|
|
1112
|
-
if (data2 && data2[0].cssUrl && data2[0].cssUrl !== "") {
|
|
1113
|
-
const link = document.createElement("link");
|
|
1114
|
-
link.rel = "stylesheet";
|
|
1115
|
-
link.href = data2[0].cssUrl;
|
|
1116
|
-
document.head.appendChild(link);
|
|
1117
|
-
console.log("Added css link", link);
|
|
1118
|
-
}
|
|
1119
1122
|
setAgentData(data2[0]);
|
|
1120
1123
|
}
|
|
1121
1124
|
} catch (error) {
|
|
@@ -1147,19 +1150,16 @@ var AgentPanel = ({
|
|
|
1147
1150
|
service: (agentData == null ? void 0 : agentData.groupId) || null,
|
|
1148
1151
|
url,
|
|
1149
1152
|
title: (_a = agentData == null ? void 0 : agentData.displayTitle) != null ? _a : "",
|
|
1150
|
-
theme: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? "light" : "dark",
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1153
|
+
theme: theme ? theme : (agentData == null ? void 0 : agentData.displayTheme) === "light" ? "light" : "dark",
|
|
1154
|
+
cssUrl: (_b = agentData == null ? void 0 : agentData.cssUrl) != null ? _b : "",
|
|
1155
|
+
height: height ? height : (_c = agentData == null ? void 0 : agentData.displayHeight) != null ? _c : "100vh",
|
|
1156
|
+
width: width ? width : (_d = agentData == null ? void 0 : agentData.displayWidth) != null ? _d : "100%",
|
|
1157
|
+
promptTemplate: (_e = agentData == null ? void 0 : agentData.displayPromptTemplate) != null ? _e : "{{prompt}}",
|
|
1158
|
+
initialMessage: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "message" ? (_f = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _f : "" : void 0,
|
|
1159
|
+
initialPrompt: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "prompt" ? (_g = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _g : "" : void 0,
|
|
1160
|
+
followOnQuestions: followOnQuestions ? followOnQuestions : (_i = (_h = agentData == null ? void 0 : agentData.displayFollowOnPrompts) == null ? void 0 : _h.split("|")) != null ? _i : [],
|
|
1157
1161
|
clearFollowOnQuestionsNextPrompt,
|
|
1158
|
-
historyChangedCallback
|
|
1159
|
-
if (history) {
|
|
1160
|
-
setFollowOnPrompt("");
|
|
1161
|
-
}
|
|
1162
|
-
},
|
|
1162
|
+
historyChangedCallback,
|
|
1163
1163
|
prismStyle: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? materialLight2 : materialDark2,
|
|
1164
1164
|
actions: [
|
|
1165
1165
|
...actions,
|
|
@@ -1167,23 +1167,25 @@ var AgentPanel = ({
|
|
|
1167
1167
|
],
|
|
1168
1168
|
followOnPrompt,
|
|
1169
1169
|
agent,
|
|
1170
|
-
placeholder: (
|
|
1171
|
-
hideInitialPrompt: (
|
|
1170
|
+
placeholder: (_j = agentData == null ? void 0 : agentData.displayPlaceholder) != null ? _j : "Type a message",
|
|
1171
|
+
hideInitialPrompt: (_k = agentData == null ? void 0 : agentData.displayHideInitialPrompt) != null ? _k : true,
|
|
1172
1172
|
data: [...data, { key: "data", data: agentData == null ? void 0 : agentData.data }],
|
|
1173
|
-
showEmailButton: (
|
|
1174
|
-
showSaveButton: (
|
|
1175
|
-
showCallToAction: (
|
|
1176
|
-
callToActionButtonText: (
|
|
1177
|
-
callToActionEmailAddress: (
|
|
1178
|
-
callToActionEmailSubject: (
|
|
1179
|
-
callToActionMustSendEmail: (
|
|
1173
|
+
showEmailButton: (_l = agentData == null ? void 0 : agentData.displayShowEmailButton) != null ? _l : true,
|
|
1174
|
+
showSaveButton: (_m = agentData == null ? void 0 : agentData.displayShowSaveButton) != null ? _m : true,
|
|
1175
|
+
showCallToAction: (_n = agentData == null ? void 0 : agentData.displayShowCallToAction) != null ? _n : false,
|
|
1176
|
+
callToActionButtonText: (_o = agentData == null ? void 0 : agentData.displayCallToActionButtonText) != null ? _o : "Submit",
|
|
1177
|
+
callToActionEmailAddress: (_p = agentData == null ? void 0 : agentData.displayCallToActionEmailAddress) != null ? _p : "",
|
|
1178
|
+
callToActionEmailSubject: (_q = agentData == null ? void 0 : agentData.displayCallToActionEmailSubject) != null ? _q : "Agent CTA Submitted",
|
|
1179
|
+
callToActionMustSendEmail: (_r = agentData == null ? void 0 : agentData.displayCallToActionMustSendEmail) != null ? _r : false,
|
|
1180
1180
|
customer: {
|
|
1181
|
-
customer_id: customer_id != null ? customer_id : "
|
|
1182
|
-
customer_user_email: customer_email != null ? customer_email : ""
|
|
1181
|
+
customer_id: customer ? customer.customer_id : customer_id != null ? customer_id : "",
|
|
1182
|
+
customer_user_email: customer ? customer.customer_user_email : customer_email != null ? customer_email : ""
|
|
1183
1183
|
},
|
|
1184
|
-
scrollToEnd: (
|
|
1185
|
-
ragQueryLimit: (
|
|
1186
|
-
ragRankLimit: (
|
|
1184
|
+
scrollToEnd: (_s = agentData == null ? void 0 : agentData.displayScrollToEnd) != null ? _s : false,
|
|
1185
|
+
ragQueryLimit: (_t = agentData == null ? void 0 : agentData.ragQueryLimit) != null ? _t : 10,
|
|
1186
|
+
ragRankLimit: (_u = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _u : 5,
|
|
1187
|
+
showPoweredBy,
|
|
1188
|
+
messages
|
|
1187
1189
|
}
|
|
1188
1190
|
));
|
|
1189
1191
|
};
|
package/package.json
CHANGED
package/src/AgentPanel.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { LLMAsAServiceCustomer } from "llmasaservice-client";
|
|
|
6
6
|
import PrismStyle from "react-syntax-highlighter";
|
|
7
7
|
|
|
8
8
|
export interface AgentPanelProps {
|
|
9
|
-
project_id: string;
|
|
9
|
+
//project_id: string;
|
|
10
10
|
//initialPrompt?: string;
|
|
11
11
|
//initialMessage?: string;
|
|
12
12
|
//title?: string;
|
|
@@ -17,10 +17,10 @@ export interface AgentPanelProps {
|
|
|
17
17
|
data?: { key: string; data: string }[];
|
|
18
18
|
thumbsUpClick?: (callId: string) => void;
|
|
19
19
|
thumbsDownClick?: (callId: string) => void;
|
|
20
|
-
|
|
20
|
+
theme?: "light" | "dark";
|
|
21
21
|
//markdownClass?: string;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
width?: string;
|
|
23
|
+
height?: string;
|
|
24
24
|
url?: string;
|
|
25
25
|
//scrollToEnd?: boolean;
|
|
26
26
|
prismStyle?: PrismStyle;
|
|
@@ -58,7 +58,7 @@ interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
61
|
-
project_id,
|
|
61
|
+
//project_id,
|
|
62
62
|
//initialPrompt = "",
|
|
63
63
|
//title = "Chat",
|
|
64
64
|
//placeholder = "Type a message",
|
|
@@ -68,16 +68,16 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
68
68
|
data = [],
|
|
69
69
|
thumbsUpClick,
|
|
70
70
|
thumbsDownClick,
|
|
71
|
-
|
|
71
|
+
theme,
|
|
72
72
|
//markdownClass = null,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
width,
|
|
74
|
+
height,
|
|
75
75
|
url = "https://chat.llmasaservice.io/",
|
|
76
76
|
//scrollToEnd = false,
|
|
77
77
|
//initialMessage = "",
|
|
78
78
|
//prismStyle = theme === "light" ? materialLight : materialDark,
|
|
79
79
|
service = null,
|
|
80
|
-
historyChangedCallback =
|
|
80
|
+
historyChangedCallback = undefined,
|
|
81
81
|
//promptTemplate = "",
|
|
82
82
|
actions = [],
|
|
83
83
|
//showSaveButton = true,
|
|
@@ -119,15 +119,6 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
119
119
|
|
|
120
120
|
const data = await response.json();
|
|
121
121
|
if (data && data.length > 0) {
|
|
122
|
-
//console.log("data", data);
|
|
123
|
-
if (data && data[0].cssUrl && data[0].cssUrl !== "") {
|
|
124
|
-
const link = document.createElement("link");
|
|
125
|
-
link.rel = "stylesheet";
|
|
126
|
-
link.href = data[0].cssUrl; // "https://dev.llmasaservice.io/themes/simple.css";
|
|
127
|
-
document.head.appendChild(link);
|
|
128
|
-
console.log("Added css link", link);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
122
|
setAgentData(data[0]);
|
|
132
123
|
}
|
|
133
124
|
} catch (error) {
|
|
@@ -167,9 +158,10 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
167
158
|
service={agentData?.groupId || null}
|
|
168
159
|
url={url}
|
|
169
160
|
title={agentData?.displayTitle ?? ""}
|
|
170
|
-
theme={agentData?.displayTheme === "light" ? "light" : "dark"}
|
|
171
|
-
|
|
172
|
-
|
|
161
|
+
theme={theme ? theme : agentData?.displayTheme === "light" ? "light" : "dark"}
|
|
162
|
+
cssUrl={agentData?.cssUrl ?? ""}
|
|
163
|
+
height={height ? height : agentData?.displayHeight ?? "100vh"}
|
|
164
|
+
width={width ? width : agentData?.displayWidth ?? "100%"}
|
|
173
165
|
promptTemplate={agentData?.displayPromptTemplate ?? "{{prompt}}"}
|
|
174
166
|
initialMessage={
|
|
175
167
|
agentData?.displayStartMessageOrPrompt === "message"
|
|
@@ -187,11 +179,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
187
179
|
: agentData?.displayFollowOnPrompts?.split("|") ?? []
|
|
188
180
|
}
|
|
189
181
|
clearFollowOnQuestionsNextPrompt={clearFollowOnQuestionsNextPrompt}
|
|
190
|
-
historyChangedCallback={
|
|
191
|
-
if (history) {
|
|
192
|
-
setFollowOnPrompt("");
|
|
193
|
-
}
|
|
194
|
-
}}
|
|
182
|
+
historyChangedCallback={historyChangedCallback}
|
|
195
183
|
prismStyle={
|
|
196
184
|
(agentData?.displayTheme === "light"
|
|
197
185
|
? materialLight
|
|
@@ -222,12 +210,16 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
222
210
|
agentData?.displayCallToActionMustSendEmail ?? false
|
|
223
211
|
}
|
|
224
212
|
customer={{
|
|
225
|
-
customer_id: customer_id ?? "
|
|
226
|
-
customer_user_email:
|
|
213
|
+
customer_id: customer ? customer.customer_id : customer_id ?? "",
|
|
214
|
+
customer_user_email: customer
|
|
215
|
+
? customer.customer_user_email
|
|
216
|
+
: customer_email ?? "",
|
|
227
217
|
}}
|
|
228
218
|
scrollToEnd={agentData?.displayScrollToEnd ?? false}
|
|
229
219
|
ragQueryLimit={agentData?.ragQueryLimit ?? 10}
|
|
230
220
|
ragRankLimit={agentData?.ragRankLimit ?? 5}
|
|
221
|
+
showPoweredBy={showPoweredBy}
|
|
222
|
+
messages={messages}
|
|
231
223
|
/>
|
|
232
224
|
)}
|
|
233
225
|
</>
|
package/src/ChatPanel.tsx
CHANGED
|
@@ -26,6 +26,7 @@ export interface ChatPanelProps {
|
|
|
26
26
|
thumbsUpClick?: (callId: string) => void;
|
|
27
27
|
thumbsDownClick?: (callId: string) => void;
|
|
28
28
|
theme?: "light" | "dark";
|
|
29
|
+
cssUrl?: string;
|
|
29
30
|
markdownClass?: string;
|
|
30
31
|
width?: string;
|
|
31
32
|
height?: string;
|
|
@@ -78,6 +79,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
78
79
|
thumbsUpClick,
|
|
79
80
|
thumbsDownClick,
|
|
80
81
|
theme = "light",
|
|
82
|
+
cssUrl = "",
|
|
81
83
|
markdownClass = null,
|
|
82
84
|
width = "300px",
|
|
83
85
|
height = "100vh",
|
|
@@ -159,6 +161,16 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
159
161
|
};
|
|
160
162
|
}, []);
|
|
161
163
|
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (cssUrl && cssUrl !== "") {
|
|
166
|
+
const link = document.createElement("link");
|
|
167
|
+
link.href = cssUrl;
|
|
168
|
+
link.rel = "stylesheet";
|
|
169
|
+
document.head.appendChild(link);
|
|
170
|
+
console.log("Added css link", link);
|
|
171
|
+
}
|
|
172
|
+
}, [cssUrl]);
|
|
173
|
+
|
|
162
174
|
// response change. Update the history
|
|
163
175
|
useEffect(() => {
|
|
164
176
|
if (response && response.length > 0) {
|