llmasaservice-ui 0.7.1 → 0.7.2

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 CHANGED
@@ -58,9 +58,48 @@ interface ChatPanelProps {
58
58
  ragQueryLimit?: number;
59
59
  ragRankLimit?: number;
60
60
  }
61
+ interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
62
+ inline?: boolean;
63
+ }
64
+ declare const ChatPanel: React.FC<ChatPanelProps & ExtraProps$1>;
65
+
66
+ interface AgentPanelProps {
67
+ project_id: string;
68
+ customer?: LLMAsAServiceCustomer;
69
+ messages?: {
70
+ role: "user" | "assistant";
71
+ content: string;
72
+ }[];
73
+ data?: {
74
+ key: string;
75
+ data: string;
76
+ }[];
77
+ thumbsUpClick?: (callId: string) => void;
78
+ thumbsDownClick?: (callId: string) => void;
79
+ url?: string;
80
+ prismStyle?: PrismStyle;
81
+ service?: string | null;
82
+ historyChangedCallback?: (history: {
83
+ [key: string]: {
84
+ content: string;
85
+ callId: string;
86
+ };
87
+ }) => void;
88
+ actions?: {
89
+ pattern: string;
90
+ type?: string;
91
+ markdown?: string;
92
+ callback?: (match: string, groups: any[]) => void;
93
+ clickCode?: string;
94
+ }[];
95
+ followOnPrompt?: string;
96
+ showPoweredBy?: boolean;
97
+ agent: string;
98
+ conversation?: string | null;
99
+ }
61
100
  interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
62
101
  inline?: boolean;
63
102
  }
64
- declare const ChatPanel: React.FC<ChatPanelProps & ExtraProps>;
103
+ declare const AgentPanel: React.FC<AgentPanelProps & ExtraProps>;
65
104
 
66
- export { ChatPanel, type ChatPanelProps };
105
+ export { AgentPanel, type AgentPanelProps, ChatPanel, type ChatPanelProps };
package/dist/index.d.ts CHANGED
@@ -58,9 +58,48 @@ interface ChatPanelProps {
58
58
  ragQueryLimit?: number;
59
59
  ragRankLimit?: number;
60
60
  }
61
+ interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
62
+ inline?: boolean;
63
+ }
64
+ declare const ChatPanel: React.FC<ChatPanelProps & ExtraProps$1>;
65
+
66
+ interface AgentPanelProps {
67
+ project_id: string;
68
+ customer?: LLMAsAServiceCustomer;
69
+ messages?: {
70
+ role: "user" | "assistant";
71
+ content: string;
72
+ }[];
73
+ data?: {
74
+ key: string;
75
+ data: string;
76
+ }[];
77
+ thumbsUpClick?: (callId: string) => void;
78
+ thumbsDownClick?: (callId: string) => void;
79
+ url?: string;
80
+ prismStyle?: PrismStyle;
81
+ service?: string | null;
82
+ historyChangedCallback?: (history: {
83
+ [key: string]: {
84
+ content: string;
85
+ callId: string;
86
+ };
87
+ }) => void;
88
+ actions?: {
89
+ pattern: string;
90
+ type?: string;
91
+ markdown?: string;
92
+ callback?: (match: string, groups: any[]) => void;
93
+ clickCode?: string;
94
+ }[];
95
+ followOnPrompt?: string;
96
+ showPoweredBy?: boolean;
97
+ agent: string;
98
+ conversation?: string | null;
99
+ }
61
100
  interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
62
101
  inline?: boolean;
63
102
  }
64
- declare const ChatPanel: React.FC<ChatPanelProps & ExtraProps>;
103
+ declare const AgentPanel: React.FC<AgentPanelProps & ExtraProps>;
65
104
 
66
- export { ChatPanel, type ChatPanelProps };
105
+ export { AgentPanel, type AgentPanelProps, ChatPanel, type ChatPanelProps };
package/dist/index.js CHANGED
@@ -79,6 +79,7 @@ var __async = (__this, __arguments, generator) => {
79
79
  // index.ts
80
80
  var llmasaservice_ui_exports = {};
81
81
  __export(llmasaservice_ui_exports, {
82
+ AgentPanel: () => AgentPanel_default,
82
83
  ChatPanel: () => ChatPanel_default
83
84
  });
84
85
  module.exports = __toCommonJS(llmasaservice_ui_exports);
@@ -1078,7 +1079,145 @@ var ChatPanel = ({
1078
1079
  ), /* @__PURE__ */ import_react3.default.createElement("div", { ref: bottomPanelRef }));
1079
1080
  };
1080
1081
  var ChatPanel_default = ChatPanel;
1082
+
1083
+ // src/AgentPanel.tsx
1084
+ var import_react4 = __toESM(require("react"));
1085
+ var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism");
1086
+ var AgentPanel = ({
1087
+ project_id,
1088
+ //initialPrompt = "",
1089
+ //title = "Chat",
1090
+ //placeholder = "Type a message",
1091
+ //hideInitialPrompt = true,
1092
+ customer = {},
1093
+ messages = [],
1094
+ data = [],
1095
+ thumbsUpClick,
1096
+ thumbsDownClick,
1097
+ //theme = "light",
1098
+ //markdownClass = null,
1099
+ //width = "300px",
1100
+ //height = "100vh",
1101
+ url = "https://chat.llmasaservice.io/",
1102
+ //scrollToEnd = false,
1103
+ //initialMessage = "",
1104
+ //prismStyle = theme === "light" ? materialLight : materialDark,
1105
+ service = null,
1106
+ historyChangedCallback = null,
1107
+ //promptTemplate = "",
1108
+ actions = [],
1109
+ //showSaveButton = true,
1110
+ //showEmailButton = true,
1111
+ //followOnQuestions = [],
1112
+ //clearFollowOnQuestionsNextPrompt = false,
1113
+ //followOnPrompt = "",
1114
+ showPoweredBy = true,
1115
+ agent,
1116
+ conversation = null
1117
+ //showCallToAction = false,
1118
+ //callToActionButtonText = "Submit",
1119
+ //callToActionEmailAddress = "",
1120
+ //callToActionEmailSubject = "Agent CTA submitted",
1121
+ //callToActionMustSendEmail = false,
1122
+ //ragQueryLimit = 10,
1123
+ //ragRankLimit = 5,
1124
+ }) => {
1125
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
1126
+ const [followOnPrompt, setFollowOnPrompt] = (0, import_react4.useState)("");
1127
+ const [followOnQuestions, setFollowOnQuestions] = (0, import_react4.useState)(
1128
+ null
1129
+ );
1130
+ const searchParams = new URLSearchParams(location.search);
1131
+ const customer_id = searchParams.get("customer_id") || "";
1132
+ const customer_email = searchParams.get("customer_email") || "";
1133
+ const [agentData, setAgentData] = (0, import_react4.useState)(null);
1134
+ (0, import_react4.useEffect)(() => {
1135
+ const fetchAgentData = () => __async(void 0, null, function* () {
1136
+ try {
1137
+ const response = yield fetch(
1138
+ `https://api.llmasaservice.io/agents/${agent}`,
1139
+ {
1140
+ method: "GET",
1141
+ headers: {
1142
+ "Content-Type": "application/json"
1143
+ }
1144
+ }
1145
+ );
1146
+ const data2 = yield response.json();
1147
+ if (data2 && data2.length > 0) {
1148
+ setAgentData(data2[0]);
1149
+ }
1150
+ } catch (error) {
1151
+ console.error("Error fetching agent data:", error);
1152
+ }
1153
+ });
1154
+ if (agent && agent !== "") {
1155
+ fetchAgentData();
1156
+ }
1157
+ }, [agent]);
1158
+ const getActionsArraySafely = (actionsString) => {
1159
+ let actions2 = [];
1160
+ if (actionsString && actionsString !== "") {
1161
+ try {
1162
+ actions2 = JSON.parse(actionsString);
1163
+ if (!Array.isArray(actions2)) {
1164
+ throw new Error("Parsed actions is not an array");
1165
+ }
1166
+ } catch (error) {
1167
+ actions2 = [];
1168
+ }
1169
+ }
1170
+ return actions2;
1171
+ };
1172
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(
1173
+ ChatPanel_default,
1174
+ {
1175
+ project_id: agentData == null ? void 0 : agentData.projectId,
1176
+ service: (agentData == null ? void 0 : agentData.groupId) || null,
1177
+ url,
1178
+ title: (_a = agentData == null ? void 0 : agentData.displayTitle) != null ? _a : "Chat Agent",
1179
+ theme: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? "light" : "dark",
1180
+ height: (_b = agentData == null ? void 0 : agentData.displayHeight) != null ? _b : "75vh",
1181
+ width: (_c = agentData == null ? void 0 : agentData.displayWidth) != null ? _c : "100%",
1182
+ promptTemplate: (_d = agentData == null ? void 0 : agentData.displayPromptTemplate) != null ? _d : "{{prompt}}",
1183
+ initialMessage: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "message" ? (_e = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _e : "" : void 0,
1184
+ initialPrompt: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "prompt" ? (_f = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _f : "" : void 0,
1185
+ followOnQuestions: followOnQuestions ? followOnQuestions : (_h = (_g = agentData == null ? void 0 : agentData.displayFollowOnPrompts) == null ? void 0 : _g.split("|")) != null ? _h : [],
1186
+ historyChangedCallback: (history) => {
1187
+ if (history) {
1188
+ setFollowOnPrompt("");
1189
+ }
1190
+ },
1191
+ prismStyle: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? import_prism.materialLight : import_prism.materialDark,
1192
+ actions: [
1193
+ ...actions,
1194
+ ...getActionsArraySafely(agentData == null ? void 0 : agentData.displayActions)
1195
+ ],
1196
+ followOnPrompt,
1197
+ agent,
1198
+ placeholder: (_i = agentData == null ? void 0 : agentData.displayPlaceholder) != null ? _i : "Type a message",
1199
+ hideInitialPrompt: (_j = agentData == null ? void 0 : agentData.displayHideInitialPrompt) != null ? _j : true,
1200
+ data: [...data, { key: "data", data: agentData == null ? void 0 : agentData.data }],
1201
+ showEmailButton: (_k = agentData == null ? void 0 : agentData.displayShowEmailButton) != null ? _k : true,
1202
+ showSaveButton: (_l = agentData == null ? void 0 : agentData.displayShowSaveButton) != null ? _l : true,
1203
+ showCallToAction: (_m = agentData == null ? void 0 : agentData.displayShowCallToAction) != null ? _m : false,
1204
+ callToActionButtonText: (_n = agentData == null ? void 0 : agentData.displayCallToActionButtonText) != null ? _n : "Submit",
1205
+ callToActionEmailAddress: (_o = agentData == null ? void 0 : agentData.displayCallToActionEmailAddress) != null ? _o : "",
1206
+ callToActionEmailSubject: (_p = agentData == null ? void 0 : agentData.displayCallToActionEmailSubject) != null ? _p : "Agent CTA Submitted",
1207
+ callToActionMustSendEmail: (_q = agentData == null ? void 0 : agentData.displayCallToActionMustSendEmail) != null ? _q : false,
1208
+ customer: {
1209
+ customer_id: customer_id != null ? customer_id : "default",
1210
+ customer_user_email: customer_email != null ? customer_email : ""
1211
+ },
1212
+ scrollToEnd: (_r = agentData == null ? void 0 : agentData.displayScrollToEnd) != null ? _r : false,
1213
+ ragQueryLimit: (_s = agentData == null ? void 0 : agentData.ragQueryLimit) != null ? _s : 10,
1214
+ ragRankLimit: (_t = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _t : 5
1215
+ }
1216
+ ));
1217
+ };
1218
+ var AgentPanel_default = AgentPanel;
1081
1219
  // Annotate the CommonJS export names for ESM import in node:
1082
1220
  0 && (module.exports = {
1221
+ AgentPanel,
1083
1222
  ChatPanel
1084
1223
  });
package/dist/index.mjs CHANGED
@@ -1045,6 +1045,147 @@ var ChatPanel = ({
1045
1045
  ), /* @__PURE__ */ React3.createElement("div", { ref: bottomPanelRef }));
1046
1046
  };
1047
1047
  var ChatPanel_default = ChatPanel;
1048
+
1049
+ // src/AgentPanel.tsx
1050
+ import React4, { useEffect as useEffect2, useState as useState4 } from "react";
1051
+ import {
1052
+ materialDark as materialDark2,
1053
+ materialLight as materialLight2
1054
+ } from "react-syntax-highlighter/dist/esm/styles/prism";
1055
+ var AgentPanel = ({
1056
+ project_id,
1057
+ //initialPrompt = "",
1058
+ //title = "Chat",
1059
+ //placeholder = "Type a message",
1060
+ //hideInitialPrompt = true,
1061
+ customer = {},
1062
+ messages = [],
1063
+ data = [],
1064
+ thumbsUpClick,
1065
+ thumbsDownClick,
1066
+ //theme = "light",
1067
+ //markdownClass = null,
1068
+ //width = "300px",
1069
+ //height = "100vh",
1070
+ url = "https://chat.llmasaservice.io/",
1071
+ //scrollToEnd = false,
1072
+ //initialMessage = "",
1073
+ //prismStyle = theme === "light" ? materialLight : materialDark,
1074
+ service = null,
1075
+ historyChangedCallback = null,
1076
+ //promptTemplate = "",
1077
+ actions = [],
1078
+ //showSaveButton = true,
1079
+ //showEmailButton = true,
1080
+ //followOnQuestions = [],
1081
+ //clearFollowOnQuestionsNextPrompt = false,
1082
+ //followOnPrompt = "",
1083
+ showPoweredBy = true,
1084
+ agent,
1085
+ conversation = null
1086
+ //showCallToAction = false,
1087
+ //callToActionButtonText = "Submit",
1088
+ //callToActionEmailAddress = "",
1089
+ //callToActionEmailSubject = "Agent CTA submitted",
1090
+ //callToActionMustSendEmail = false,
1091
+ //ragQueryLimit = 10,
1092
+ //ragRankLimit = 5,
1093
+ }) => {
1094
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
1095
+ const [followOnPrompt, setFollowOnPrompt] = useState4("");
1096
+ const [followOnQuestions, setFollowOnQuestions] = useState4(
1097
+ null
1098
+ );
1099
+ const searchParams = new URLSearchParams(location.search);
1100
+ const customer_id = searchParams.get("customer_id") || "";
1101
+ const customer_email = searchParams.get("customer_email") || "";
1102
+ const [agentData, setAgentData] = useState4(null);
1103
+ useEffect2(() => {
1104
+ const fetchAgentData = () => __async(void 0, null, function* () {
1105
+ try {
1106
+ const response = yield fetch(
1107
+ `https://api.llmasaservice.io/agents/${agent}`,
1108
+ {
1109
+ method: "GET",
1110
+ headers: {
1111
+ "Content-Type": "application/json"
1112
+ }
1113
+ }
1114
+ );
1115
+ const data2 = yield response.json();
1116
+ if (data2 && data2.length > 0) {
1117
+ setAgentData(data2[0]);
1118
+ }
1119
+ } catch (error) {
1120
+ console.error("Error fetching agent data:", error);
1121
+ }
1122
+ });
1123
+ if (agent && agent !== "") {
1124
+ fetchAgentData();
1125
+ }
1126
+ }, [agent]);
1127
+ const getActionsArraySafely = (actionsString) => {
1128
+ let actions2 = [];
1129
+ if (actionsString && actionsString !== "") {
1130
+ try {
1131
+ actions2 = JSON.parse(actionsString);
1132
+ if (!Array.isArray(actions2)) {
1133
+ throw new Error("Parsed actions is not an array");
1134
+ }
1135
+ } catch (error) {
1136
+ actions2 = [];
1137
+ }
1138
+ }
1139
+ return actions2;
1140
+ };
1141
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
1142
+ ChatPanel_default,
1143
+ {
1144
+ project_id: agentData == null ? void 0 : agentData.projectId,
1145
+ service: (agentData == null ? void 0 : agentData.groupId) || null,
1146
+ url,
1147
+ title: (_a = agentData == null ? void 0 : agentData.displayTitle) != null ? _a : "Chat Agent",
1148
+ theme: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? "light" : "dark",
1149
+ height: (_b = agentData == null ? void 0 : agentData.displayHeight) != null ? _b : "75vh",
1150
+ width: (_c = agentData == null ? void 0 : agentData.displayWidth) != null ? _c : "100%",
1151
+ promptTemplate: (_d = agentData == null ? void 0 : agentData.displayPromptTemplate) != null ? _d : "{{prompt}}",
1152
+ initialMessage: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "message" ? (_e = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _e : "" : void 0,
1153
+ initialPrompt: (agentData == null ? void 0 : agentData.displayStartMessageOrPrompt) === "prompt" ? (_f = agentData == null ? void 0 : agentData.displayInitialMessageOrPrompt) != null ? _f : "" : void 0,
1154
+ followOnQuestions: followOnQuestions ? followOnQuestions : (_h = (_g = agentData == null ? void 0 : agentData.displayFollowOnPrompts) == null ? void 0 : _g.split("|")) != null ? _h : [],
1155
+ historyChangedCallback: (history) => {
1156
+ if (history) {
1157
+ setFollowOnPrompt("");
1158
+ }
1159
+ },
1160
+ prismStyle: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? materialLight2 : materialDark2,
1161
+ actions: [
1162
+ ...actions,
1163
+ ...getActionsArraySafely(agentData == null ? void 0 : agentData.displayActions)
1164
+ ],
1165
+ followOnPrompt,
1166
+ agent,
1167
+ placeholder: (_i = agentData == null ? void 0 : agentData.displayPlaceholder) != null ? _i : "Type a message",
1168
+ hideInitialPrompt: (_j = agentData == null ? void 0 : agentData.displayHideInitialPrompt) != null ? _j : true,
1169
+ data: [...data, { key: "data", data: agentData == null ? void 0 : agentData.data }],
1170
+ showEmailButton: (_k = agentData == null ? void 0 : agentData.displayShowEmailButton) != null ? _k : true,
1171
+ showSaveButton: (_l = agentData == null ? void 0 : agentData.displayShowSaveButton) != null ? _l : true,
1172
+ showCallToAction: (_m = agentData == null ? void 0 : agentData.displayShowCallToAction) != null ? _m : false,
1173
+ callToActionButtonText: (_n = agentData == null ? void 0 : agentData.displayCallToActionButtonText) != null ? _n : "Submit",
1174
+ callToActionEmailAddress: (_o = agentData == null ? void 0 : agentData.displayCallToActionEmailAddress) != null ? _o : "",
1175
+ callToActionEmailSubject: (_p = agentData == null ? void 0 : agentData.displayCallToActionEmailSubject) != null ? _p : "Agent CTA Submitted",
1176
+ callToActionMustSendEmail: (_q = agentData == null ? void 0 : agentData.displayCallToActionMustSendEmail) != null ? _q : false,
1177
+ customer: {
1178
+ customer_id: customer_id != null ? customer_id : "default",
1179
+ customer_user_email: customer_email != null ? customer_email : ""
1180
+ },
1181
+ scrollToEnd: (_r = agentData == null ? void 0 : agentData.displayScrollToEnd) != null ? _r : false,
1182
+ ragQueryLimit: (_s = agentData == null ? void 0 : agentData.ragQueryLimit) != null ? _s : 10,
1183
+ ragRankLimit: (_t = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _t : 5
1184
+ }
1185
+ ));
1186
+ };
1187
+ var AgentPanel_default = AgentPanel;
1048
1188
  export {
1189
+ AgentPanel_default as AgentPanel,
1049
1190
  ChatPanel_default as ChatPanel
1050
1191
  };
package/index.ts CHANGED
@@ -2,4 +2,7 @@
2
2
  import ChatPanel, { ChatPanelProps } from './src/ChatPanel';
3
3
 
4
4
  // Export the ChatPanel component and its props
5
- export { ChatPanel, ChatPanelProps };
5
+ export { ChatPanel, ChatPanelProps };
6
+
7
+ import AgentPanel, { AgentPanelProps } from './src/AgentPanel';
8
+ export { AgentPanel, AgentPanelProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",