llmasaservice-ui 0.7.13 → 0.7.14

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
@@ -33,9 +33,9 @@ interface ChatPanelProps {
33
33
  [key: string]: {
34
34
  content: string;
35
35
  callId: string;
36
- idle: boolean;
37
36
  };
38
37
  }) => void;
38
+ responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
39
39
  promptTemplate?: string;
40
40
  actions?: {
41
41
  pattern: string;
@@ -88,9 +88,9 @@ interface AgentPanelProps {
88
88
  [key: string]: {
89
89
  content: string;
90
90
  callId: string;
91
- idle: boolean;
92
91
  };
93
92
  }) => void;
93
+ responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
94
94
  actions?: {
95
95
  pattern: string;
96
96
  type?: string;
package/dist/index.d.ts CHANGED
@@ -33,9 +33,9 @@ interface ChatPanelProps {
33
33
  [key: string]: {
34
34
  content: string;
35
35
  callId: string;
36
- idle: boolean;
37
36
  };
38
37
  }) => void;
38
+ responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
39
39
  promptTemplate?: string;
40
40
  actions?: {
41
41
  pattern: string;
@@ -88,9 +88,9 @@ interface AgentPanelProps {
88
88
  [key: string]: {
89
89
  content: string;
90
90
  callId: string;
91
- idle: boolean;
92
91
  };
93
92
  }) => void;
93
+ responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
94
94
  actions?: {
95
95
  pattern: string;
96
96
  type?: string;
package/dist/index.js CHANGED
@@ -185,6 +185,7 @@ var ChatPanel = ({
185
185
  prismStyle = theme === "light" ? import_material_light.default : import_material_dark.default,
186
186
  service = null,
187
187
  historyChangedCallback = null,
188
+ responseCompleteCallback = null,
188
189
  promptTemplate = "",
189
190
  actions = [],
190
191
  showSaveButton = true,
@@ -228,6 +229,12 @@ var ChatPanel = ({
228
229
  sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
229
230
  };
230
231
  const responseAreaRef = (0, import_react3.useRef)(null);
232
+ (0, import_react3.useEffect)(() => {
233
+ if (responseCompleteCallback) {
234
+ if (lastCallId && lastCallId !== "" && idle)
235
+ responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
236
+ }
237
+ }, [idle]);
231
238
  (0, import_react3.useEffect)(() => {
232
239
  const handleBeforeUnload = (event) => {
233
240
  if (callToActionMustSendEmail && showCallToAction && callToActionEmailAddress && callToActionEmailAddress !== "" && !hasSentCallToActionEmail) {
@@ -298,7 +305,7 @@ var ChatPanel = ({
298
305
  }
299
306
  setHistory((prevHistory) => {
300
307
  return __spreadProps(__spreadValues({}, prevHistory), {
301
- [lastKey != null ? lastKey : ""]: { content: newResponse, callId: lastCallId, idle }
308
+ [lastKey != null ? lastKey : ""]: { content: newResponse, callId: lastCallId }
302
309
  });
303
310
  });
304
311
  }
@@ -375,8 +382,7 @@ var ChatPanel = ({
375
382
  return __spreadProps(__spreadValues({}, prevHistory), {
376
383
  [lastKey != null ? lastKey : ""]: {
377
384
  content: response + "\n\n(response cancelled)",
378
- callId: lastCallId,
379
- idle: true
385
+ callId: lastCallId
380
386
  }
381
387
  });
382
388
  });
@@ -423,7 +429,7 @@ var ChatPanel = ({
423
429
  }
424
430
  setHistory((prevHistory) => {
425
431
  return __spreadProps(__spreadValues({}, prevHistory), {
426
- [promptKey != null ? promptKey : ""]: { content: "", callId: "", idle: false }
432
+ [promptKey != null ? promptKey : ""]: { content: "", callId: "" }
427
433
  });
428
434
  });
429
435
  if (initialPrompt && initialPrompt !== "" && Object.keys(history).length === 1 || (!initialPrompt || initialPrompt === "") && Object.keys(history).length === 0) {
@@ -1116,6 +1122,7 @@ var AgentPanel = ({
1116
1122
  //prismStyle = theme === "light" ? materialLight : materialDark,
1117
1123
  service = null,
1118
1124
  historyChangedCallback = void 0,
1125
+ responseCompleteCallback = void 0,
1119
1126
  //promptTemplate = "",
1120
1127
  actions = [],
1121
1128
  //showSaveButton = true,
@@ -1195,6 +1202,7 @@ var AgentPanel = ({
1195
1202
  followOnQuestions: followOnQuestions && followOnQuestions.length > 0 ? followOnQuestions : (_i = (_h = agentData == null ? void 0 : agentData.displayFollowOnPrompts) == null ? void 0 : _h.split("|")) != null ? _i : [],
1196
1203
  clearFollowOnQuestionsNextPrompt,
1197
1204
  historyChangedCallback,
1205
+ responseCompleteCallback,
1198
1206
  prismStyle: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? import_material_light2.default : import_material_dark2.default,
1199
1207
  actions: [
1200
1208
  ...actions,
package/dist/index.mjs CHANGED
@@ -151,6 +151,7 @@ var ChatPanel = ({
151
151
  prismStyle = theme === "light" ? materialLight : materialDark,
152
152
  service = null,
153
153
  historyChangedCallback = null,
154
+ responseCompleteCallback = null,
154
155
  promptTemplate = "",
155
156
  actions = [],
156
157
  showSaveButton = true,
@@ -194,6 +195,12 @@ var ChatPanel = ({
194
195
  sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
195
196
  };
196
197
  const responseAreaRef = useRef(null);
198
+ useEffect(() => {
199
+ if (responseCompleteCallback) {
200
+ if (lastCallId && lastCallId !== "" && idle)
201
+ responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
202
+ }
203
+ }, [idle]);
197
204
  useEffect(() => {
198
205
  const handleBeforeUnload = (event) => {
199
206
  if (callToActionMustSendEmail && showCallToAction && callToActionEmailAddress && callToActionEmailAddress !== "" && !hasSentCallToActionEmail) {
@@ -264,7 +271,7 @@ var ChatPanel = ({
264
271
  }
265
272
  setHistory((prevHistory) => {
266
273
  return __spreadProps(__spreadValues({}, prevHistory), {
267
- [lastKey != null ? lastKey : ""]: { content: newResponse, callId: lastCallId, idle }
274
+ [lastKey != null ? lastKey : ""]: { content: newResponse, callId: lastCallId }
268
275
  });
269
276
  });
270
277
  }
@@ -341,8 +348,7 @@ var ChatPanel = ({
341
348
  return __spreadProps(__spreadValues({}, prevHistory), {
342
349
  [lastKey != null ? lastKey : ""]: {
343
350
  content: response + "\n\n(response cancelled)",
344
- callId: lastCallId,
345
- idle: true
351
+ callId: lastCallId
346
352
  }
347
353
  });
348
354
  });
@@ -389,7 +395,7 @@ var ChatPanel = ({
389
395
  }
390
396
  setHistory((prevHistory) => {
391
397
  return __spreadProps(__spreadValues({}, prevHistory), {
392
- [promptKey != null ? promptKey : ""]: { content: "", callId: "", idle: false }
398
+ [promptKey != null ? promptKey : ""]: { content: "", callId: "" }
393
399
  });
394
400
  });
395
401
  if (initialPrompt && initialPrompt !== "" && Object.keys(history).length === 1 || (!initialPrompt || initialPrompt === "") && Object.keys(history).length === 0) {
@@ -1082,6 +1088,7 @@ var AgentPanel = ({
1082
1088
  //prismStyle = theme === "light" ? materialLight : materialDark,
1083
1089
  service = null,
1084
1090
  historyChangedCallback = void 0,
1091
+ responseCompleteCallback = void 0,
1085
1092
  //promptTemplate = "",
1086
1093
  actions = [],
1087
1094
  //showSaveButton = true,
@@ -1161,6 +1168,7 @@ var AgentPanel = ({
1161
1168
  followOnQuestions: followOnQuestions && followOnQuestions.length > 0 ? followOnQuestions : (_i = (_h = agentData == null ? void 0 : agentData.displayFollowOnPrompts) == null ? void 0 : _h.split("|")) != null ? _i : [],
1162
1169
  clearFollowOnQuestionsNextPrompt,
1163
1170
  historyChangedCallback,
1171
+ responseCompleteCallback,
1164
1172
  prismStyle: (agentData == null ? void 0 : agentData.displayTheme) === "light" ? materialLight2 : materialDark2,
1165
1173
  actions: [
1166
1174
  ...actions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,8 +26,9 @@ export interface AgentPanelProps {
26
26
  prismStyle?: PrismStyle;
27
27
  service?: string | null;
28
28
  historyChangedCallback?: (history: {
29
- [key: string]: { content: string; callId: string; idle: boolean };
29
+ [key: string]: { content: string; callId: string };
30
30
  }) => void;
31
+ responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
31
32
  //promptTemplate?: string;
32
33
  actions?: {
33
34
  pattern: string;
@@ -78,6 +79,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
78
79
  //prismStyle = theme === "light" ? materialLight : materialDark,
79
80
  service = null,
80
81
  historyChangedCallback = undefined,
82
+ responseCompleteCallback = undefined,
81
83
  //promptTemplate = "",
82
84
  actions = [],
83
85
  //showSaveButton = true,
@@ -180,6 +182,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
180
182
  }
181
183
  clearFollowOnQuestionsNextPrompt={clearFollowOnQuestionsNextPrompt}
182
184
  historyChangedCallback={historyChangedCallback}
185
+ responseCompleteCallback={responseCompleteCallback}
183
186
  prismStyle={
184
187
  (agentData?.displayTheme === "light"
185
188
  ? materialLight
package/src/ChatPanel.tsx CHANGED
@@ -35,8 +35,9 @@ export interface ChatPanelProps {
35
35
  prismStyle?: PrismStyle;
36
36
  service?: string | null;
37
37
  historyChangedCallback?: (history: {
38
- [key: string]: { content: string; callId: string; idle: boolean };
38
+ [key: string]: { content: string; callId: string };
39
39
  }) => void;
40
+ responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
40
41
  promptTemplate?: string;
41
42
  actions?: {
42
43
  pattern: string;
@@ -89,6 +90,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
89
90
  prismStyle = theme === "light" ? materialLight : materialDark,
90
91
  service = null,
91
92
  historyChangedCallback = null,
93
+ responseCompleteCallback = null,
92
94
  promptTemplate = "",
93
95
  actions = [],
94
96
  showSaveButton = true,
@@ -119,7 +121,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
119
121
  const [nextPrompt, setNextPrompt] = useState("");
120
122
  const [lastController, setLastController] = useState(new AbortController());
121
123
  const [history, setHistory] = useState<{
122
- [prompt: string]: { content: string; callId: string; idle: boolean };
124
+ [prompt: string]: { content: string; callId: string };
123
125
  }>({});
124
126
  const [isLoading, setIsLoading] = useState(false);
125
127
  const [lastPrompt, setLastPrompt] = useState<string | null>(null);
@@ -139,6 +141,13 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
139
141
 
140
142
  const responseAreaRef = useRef(null);
141
143
 
144
+ useEffect(() => {
145
+ if (responseCompleteCallback) {
146
+ if (lastCallId && lastCallId !== "" && idle)
147
+ responseCompleteCallback(lastCallId, lastPrompt ?? "", response);
148
+ }
149
+ }, [idle]);
150
+
142
151
  useEffect(() => {
143
152
  const handleBeforeUnload = (event: BeforeUnloadEvent) => {
144
153
  if (
@@ -231,7 +240,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
231
240
  setHistory((prevHistory) => {
232
241
  return {
233
242
  ...prevHistory,
234
- [lastKey ?? ""]: { content: newResponse, callId: lastCallId, idle },
243
+ [lastKey ?? ""]: { content: newResponse, callId: lastCallId },
235
244
  };
236
245
  });
237
246
  }
@@ -321,7 +330,6 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
321
330
  [lastKey ?? ""]: {
322
331
  content: response + "\n\n(response cancelled)",
323
332
  callId: lastCallId,
324
- idle: true,
325
333
  },
326
334
  };
327
335
  });
@@ -387,7 +395,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
387
395
  setHistory((prevHistory) => {
388
396
  return {
389
397
  ...prevHistory,
390
- [promptKey ?? ""]: { content: "", callId: "", idle: false },
398
+ [promptKey ?? ""]: { content: "", callId: "" },
391
399
  };
392
400
  });
393
401
 
@@ -433,7 +441,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
433
441
  };
434
442
 
435
443
  const replaceHistory = (newHistory: {
436
- [prompt: string]: { content: string; callId: string; idle: boolean };
444
+ [prompt: string]: { content: string; callId: string };
437
445
  }) => {
438
446
  setHistory(newHistory);
439
447
  };