llmasaservice-ui 0.8.21 → 0.9.1
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.js +80 -70
- package/dist/index.mjs +80 -70
- package/package.json +1 -1
- package/src/ChatPanel.tsx +91 -83
package/dist/index.js
CHANGED
|
@@ -229,6 +229,7 @@ var ChatPanel = ({
|
|
|
229
229
|
);
|
|
230
230
|
const handleSendEmail = (to, from) => {
|
|
231
231
|
sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
|
|
232
|
+
interactionClicked(lastCallId, "email", to);
|
|
232
233
|
};
|
|
233
234
|
const responseAreaRef = (0, import_react3.useRef)(null);
|
|
234
235
|
let publicAPIUrl = "https://api.llmasaservice.io";
|
|
@@ -345,6 +346,7 @@ var ChatPanel = ({
|
|
|
345
346
|
try {
|
|
346
347
|
const func = new Function("match", action.clickCode);
|
|
347
348
|
func(match);
|
|
349
|
+
interactionClicked(lastCallId, "action");
|
|
348
350
|
} catch (error) {
|
|
349
351
|
console.error("Error executing clickCode:", error);
|
|
350
352
|
}
|
|
@@ -371,22 +373,24 @@ var ChatPanel = ({
|
|
|
371
373
|
if (initialPrompt && initialPrompt !== "") {
|
|
372
374
|
if (initialPrompt !== lastPrompt) {
|
|
373
375
|
setIsLoading(true);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
376
|
+
ensureConversation().then((convId) => {
|
|
377
|
+
if (lastController) stop(lastController);
|
|
378
|
+
const controller = new AbortController();
|
|
379
|
+
send(
|
|
380
|
+
initialPrompt,
|
|
381
|
+
messages,
|
|
382
|
+
data,
|
|
383
|
+
true,
|
|
384
|
+
true,
|
|
385
|
+
service,
|
|
386
|
+
convId,
|
|
387
|
+
controller
|
|
388
|
+
);
|
|
389
|
+
setLastPrompt(initialPrompt);
|
|
390
|
+
setLastKey(initialPrompt);
|
|
391
|
+
setLastController(controller);
|
|
392
|
+
setHistory({});
|
|
393
|
+
});
|
|
390
394
|
}
|
|
391
395
|
}
|
|
392
396
|
}, [initialPrompt]);
|
|
@@ -427,36 +431,36 @@ var ChatPanel = ({
|
|
|
427
431
|
continueChat(followOnPrompt);
|
|
428
432
|
}
|
|
429
433
|
}, [followOnPrompt]);
|
|
434
|
+
const ensureConversation = () => {
|
|
435
|
+
var _a, _b;
|
|
436
|
+
if ((!currentConversation || currentConversation === "") && createConversationOnFirstChat) {
|
|
437
|
+
return fetch(`${publicAPIUrl}/conversations`, {
|
|
438
|
+
method: "POST",
|
|
439
|
+
headers: {
|
|
440
|
+
"Content-Type": "application/json"
|
|
441
|
+
},
|
|
442
|
+
body: JSON.stringify({
|
|
443
|
+
project_id: project_id != null ? project_id : "",
|
|
444
|
+
agentId: agent,
|
|
445
|
+
customerId: (_a = customer == null ? void 0 : customer.customer_id) != null ? _a : null,
|
|
446
|
+
customerEmail: (_b = customer == null ? void 0 : customer.customer_name) != null ? _b : null
|
|
447
|
+
})
|
|
448
|
+
}).then((res) => res.json()).then((newConvo) => {
|
|
449
|
+
if (newConvo == null ? void 0 : newConvo.id) {
|
|
450
|
+
console.log("new conversation created", newConvo.id);
|
|
451
|
+
setCurrentConversation(newConvo.id);
|
|
452
|
+
return newConvo.id;
|
|
453
|
+
}
|
|
454
|
+
return "";
|
|
455
|
+
}).catch((error) => {
|
|
456
|
+
console.error("Error creating new conversation", error);
|
|
457
|
+
return "";
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return Promise.resolve(currentConversation);
|
|
461
|
+
};
|
|
430
462
|
const continueChat = (suggestion) => {
|
|
431
463
|
console.log("continueChat", suggestion);
|
|
432
|
-
const ensureConversation = () => {
|
|
433
|
-
var _a, _b;
|
|
434
|
-
if ((!currentConversation || currentConversation === "") && createConversationOnFirstChat) {
|
|
435
|
-
return fetch(`${publicAPIUrl}/conversations`, {
|
|
436
|
-
method: "POST",
|
|
437
|
-
headers: {
|
|
438
|
-
"Content-Type": "application/json"
|
|
439
|
-
},
|
|
440
|
-
body: JSON.stringify({
|
|
441
|
-
project_id: project_id != null ? project_id : "",
|
|
442
|
-
agentId: agent,
|
|
443
|
-
customerId: (_a = customer == null ? void 0 : customer.customer_id) != null ? _a : null,
|
|
444
|
-
customerEmail: (_b = customer == null ? void 0 : customer.customer_name) != null ? _b : null
|
|
445
|
-
})
|
|
446
|
-
}).then((res) => res.json()).then((newConvo) => {
|
|
447
|
-
if (newConvo == null ? void 0 : newConvo.id) {
|
|
448
|
-
console.log("new conversation created", newConvo.id);
|
|
449
|
-
setCurrentConversation(newConvo.id);
|
|
450
|
-
return newConvo.id;
|
|
451
|
-
}
|
|
452
|
-
return "";
|
|
453
|
-
}).catch((error) => {
|
|
454
|
-
console.error("Error creating new conversation", error);
|
|
455
|
-
return "";
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
return Promise.resolve(currentConversation);
|
|
459
|
-
};
|
|
460
464
|
ensureConversation().then((convId) => {
|
|
461
465
|
var _a, _b, _c, _d;
|
|
462
466
|
if (!idle) {
|
|
@@ -553,6 +557,7 @@ var ChatPanel = ({
|
|
|
553
557
|
};
|
|
554
558
|
function copyToClipboard(text) {
|
|
555
559
|
navigator.clipboard.writeText(text);
|
|
560
|
+
interactionClicked(lastCallId, "copy");
|
|
556
561
|
}
|
|
557
562
|
const scrollToBottom = () => {
|
|
558
563
|
var _a;
|
|
@@ -729,6 +734,7 @@ var ChatPanel = ({
|
|
|
729
734
|
};
|
|
730
735
|
const handleSuggestionClick = (suggestion) => {
|
|
731
736
|
continueChat(suggestion);
|
|
737
|
+
interactionClicked(lastCallId, "suggestion");
|
|
732
738
|
};
|
|
733
739
|
const sendConversationsViaEmail = (to, subject = `Conversation History from ${title}`, from = "") => {
|
|
734
740
|
fetch(`${publicAPIUrl}/share/email`, {
|
|
@@ -747,6 +753,7 @@ var ChatPanel = ({
|
|
|
747
753
|
title
|
|
748
754
|
})
|
|
749
755
|
});
|
|
756
|
+
interactionClicked(lastCallId, "email", from);
|
|
750
757
|
};
|
|
751
758
|
const sendCallToActionEmail = (from) => __async(void 0, null, function* () {
|
|
752
759
|
const r = yield fetch(`${publicAPIUrl}/share/email`, {
|
|
@@ -768,33 +775,24 @@ var ChatPanel = ({
|
|
|
768
775
|
if (r.ok) {
|
|
769
776
|
setHasSentCallToActionEmail(true);
|
|
770
777
|
}
|
|
778
|
+
interactionClicked(lastCallId, "cta", from);
|
|
771
779
|
});
|
|
772
|
-
const
|
|
773
|
-
console.log(
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
headers: {
|
|
777
|
-
"Content-Type": "application/json"
|
|
778
|
-
},
|
|
779
|
-
body: JSON.stringify({
|
|
780
|
-
comment: "",
|
|
781
|
-
project_id: project_id != null ? project_id : ""
|
|
782
|
-
})
|
|
783
|
-
});
|
|
784
|
-
};
|
|
785
|
-
const defaultThumbsDownClick = (callId) => {
|
|
786
|
-
console.log("thumbs down", callId);
|
|
787
|
-
fetch(`${publicAPIUrl}/feedback/${callId}/thumbsdown`, {
|
|
780
|
+
const interactionClicked = (callId, action, emailaddress = "", comment = "") => __async(void 0, null, function* () {
|
|
781
|
+
console.log(`Interaction clicked: ${action} for callId: ${callId}`);
|
|
782
|
+
if (!callId || callId === "") return;
|
|
783
|
+
fetch(`${publicAPIUrl}/feedback/${callId}/${action}`, {
|
|
788
784
|
method: "POST",
|
|
789
785
|
headers: {
|
|
790
786
|
"Content-Type": "application/json"
|
|
791
787
|
},
|
|
792
788
|
body: JSON.stringify({
|
|
793
|
-
|
|
794
|
-
|
|
789
|
+
project_id: project_id != null ? project_id : "",
|
|
790
|
+
conversation_id: currentConversation != null ? currentConversation : "",
|
|
791
|
+
emailaddress,
|
|
792
|
+
comment
|
|
795
793
|
})
|
|
796
794
|
});
|
|
797
|
-
};
|
|
795
|
+
});
|
|
798
796
|
const formatPromptForDisplay = (prompt) => {
|
|
799
797
|
if (!prompt) {
|
|
800
798
|
return "";
|
|
@@ -841,7 +839,10 @@ var ChatPanel = ({
|
|
|
841
839
|
"button",
|
|
842
840
|
{
|
|
843
841
|
className: "copy-button",
|
|
844
|
-
onClick: () =>
|
|
842
|
+
onClick: () => {
|
|
843
|
+
copyToClipboard(response2.content);
|
|
844
|
+
interactionClicked(response2.callId, "copy");
|
|
845
|
+
}
|
|
845
846
|
},
|
|
846
847
|
/* @__PURE__ */ import_react3.default.createElement(
|
|
847
848
|
"svg",
|
|
@@ -870,7 +871,10 @@ var ChatPanel = ({
|
|
|
870
871
|
"button",
|
|
871
872
|
{
|
|
872
873
|
className: "thumbs-button",
|
|
873
|
-
onClick: () =>
|
|
874
|
+
onClick: () => {
|
|
875
|
+
if (thumbsUpClick) thumbsUpClick(response2.callId);
|
|
876
|
+
interactionClicked(response2.callId, "thumbsup");
|
|
877
|
+
}
|
|
874
878
|
},
|
|
875
879
|
/* @__PURE__ */ import_react3.default.createElement(
|
|
876
880
|
"svg",
|
|
@@ -886,7 +890,10 @@ var ChatPanel = ({
|
|
|
886
890
|
"button",
|
|
887
891
|
{
|
|
888
892
|
className: "thumbs-button",
|
|
889
|
-
onClick: () =>
|
|
893
|
+
onClick: () => {
|
|
894
|
+
if (thumbsDownClick) thumbsDownClick(response2.callId);
|
|
895
|
+
interactionClicked(response2.callId, "thumbsdown");
|
|
896
|
+
}
|
|
890
897
|
},
|
|
891
898
|
/* @__PURE__ */ import_react3.default.createElement(
|
|
892
899
|
"svg",
|
|
@@ -912,10 +919,13 @@ var ChatPanel = ({
|
|
|
912
919
|
"button",
|
|
913
920
|
{
|
|
914
921
|
className: "save-button",
|
|
915
|
-
onClick: () =>
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
922
|
+
onClick: () => {
|
|
923
|
+
saveHTMLToFile(
|
|
924
|
+
convertHistoryToHTML(history),
|
|
925
|
+
`conversation-${(/* @__PURE__ */ new Date()).toISOString()}.html`
|
|
926
|
+
);
|
|
927
|
+
interactionClicked(lastCallId, "save");
|
|
928
|
+
}
|
|
919
929
|
},
|
|
920
930
|
"Save Conversation"
|
|
921
931
|
), showEmailButton && /* @__PURE__ */ import_react3.default.createElement(
|
package/dist/index.mjs
CHANGED
|
@@ -195,6 +195,7 @@ var ChatPanel = ({
|
|
|
195
195
|
);
|
|
196
196
|
const handleSendEmail = (to, from) => {
|
|
197
197
|
sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
|
|
198
|
+
interactionClicked(lastCallId, "email", to);
|
|
198
199
|
};
|
|
199
200
|
const responseAreaRef = useRef(null);
|
|
200
201
|
let publicAPIUrl = "https://api.llmasaservice.io";
|
|
@@ -311,6 +312,7 @@ var ChatPanel = ({
|
|
|
311
312
|
try {
|
|
312
313
|
const func = new Function("match", action.clickCode);
|
|
313
314
|
func(match);
|
|
315
|
+
interactionClicked(lastCallId, "action");
|
|
314
316
|
} catch (error) {
|
|
315
317
|
console.error("Error executing clickCode:", error);
|
|
316
318
|
}
|
|
@@ -337,22 +339,24 @@ var ChatPanel = ({
|
|
|
337
339
|
if (initialPrompt && initialPrompt !== "") {
|
|
338
340
|
if (initialPrompt !== lastPrompt) {
|
|
339
341
|
setIsLoading(true);
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
342
|
+
ensureConversation().then((convId) => {
|
|
343
|
+
if (lastController) stop(lastController);
|
|
344
|
+
const controller = new AbortController();
|
|
345
|
+
send(
|
|
346
|
+
initialPrompt,
|
|
347
|
+
messages,
|
|
348
|
+
data,
|
|
349
|
+
true,
|
|
350
|
+
true,
|
|
351
|
+
service,
|
|
352
|
+
convId,
|
|
353
|
+
controller
|
|
354
|
+
);
|
|
355
|
+
setLastPrompt(initialPrompt);
|
|
356
|
+
setLastKey(initialPrompt);
|
|
357
|
+
setLastController(controller);
|
|
358
|
+
setHistory({});
|
|
359
|
+
});
|
|
356
360
|
}
|
|
357
361
|
}
|
|
358
362
|
}, [initialPrompt]);
|
|
@@ -393,36 +397,36 @@ var ChatPanel = ({
|
|
|
393
397
|
continueChat(followOnPrompt);
|
|
394
398
|
}
|
|
395
399
|
}, [followOnPrompt]);
|
|
400
|
+
const ensureConversation = () => {
|
|
401
|
+
var _a, _b;
|
|
402
|
+
if ((!currentConversation || currentConversation === "") && createConversationOnFirstChat) {
|
|
403
|
+
return fetch(`${publicAPIUrl}/conversations`, {
|
|
404
|
+
method: "POST",
|
|
405
|
+
headers: {
|
|
406
|
+
"Content-Type": "application/json"
|
|
407
|
+
},
|
|
408
|
+
body: JSON.stringify({
|
|
409
|
+
project_id: project_id != null ? project_id : "",
|
|
410
|
+
agentId: agent,
|
|
411
|
+
customerId: (_a = customer == null ? void 0 : customer.customer_id) != null ? _a : null,
|
|
412
|
+
customerEmail: (_b = customer == null ? void 0 : customer.customer_name) != null ? _b : null
|
|
413
|
+
})
|
|
414
|
+
}).then((res) => res.json()).then((newConvo) => {
|
|
415
|
+
if (newConvo == null ? void 0 : newConvo.id) {
|
|
416
|
+
console.log("new conversation created", newConvo.id);
|
|
417
|
+
setCurrentConversation(newConvo.id);
|
|
418
|
+
return newConvo.id;
|
|
419
|
+
}
|
|
420
|
+
return "";
|
|
421
|
+
}).catch((error) => {
|
|
422
|
+
console.error("Error creating new conversation", error);
|
|
423
|
+
return "";
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
return Promise.resolve(currentConversation);
|
|
427
|
+
};
|
|
396
428
|
const continueChat = (suggestion) => {
|
|
397
429
|
console.log("continueChat", suggestion);
|
|
398
|
-
const ensureConversation = () => {
|
|
399
|
-
var _a, _b;
|
|
400
|
-
if ((!currentConversation || currentConversation === "") && createConversationOnFirstChat) {
|
|
401
|
-
return fetch(`${publicAPIUrl}/conversations`, {
|
|
402
|
-
method: "POST",
|
|
403
|
-
headers: {
|
|
404
|
-
"Content-Type": "application/json"
|
|
405
|
-
},
|
|
406
|
-
body: JSON.stringify({
|
|
407
|
-
project_id: project_id != null ? project_id : "",
|
|
408
|
-
agentId: agent,
|
|
409
|
-
customerId: (_a = customer == null ? void 0 : customer.customer_id) != null ? _a : null,
|
|
410
|
-
customerEmail: (_b = customer == null ? void 0 : customer.customer_name) != null ? _b : null
|
|
411
|
-
})
|
|
412
|
-
}).then((res) => res.json()).then((newConvo) => {
|
|
413
|
-
if (newConvo == null ? void 0 : newConvo.id) {
|
|
414
|
-
console.log("new conversation created", newConvo.id);
|
|
415
|
-
setCurrentConversation(newConvo.id);
|
|
416
|
-
return newConvo.id;
|
|
417
|
-
}
|
|
418
|
-
return "";
|
|
419
|
-
}).catch((error) => {
|
|
420
|
-
console.error("Error creating new conversation", error);
|
|
421
|
-
return "";
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
return Promise.resolve(currentConversation);
|
|
425
|
-
};
|
|
426
430
|
ensureConversation().then((convId) => {
|
|
427
431
|
var _a, _b, _c, _d;
|
|
428
432
|
if (!idle) {
|
|
@@ -519,6 +523,7 @@ var ChatPanel = ({
|
|
|
519
523
|
};
|
|
520
524
|
function copyToClipboard(text) {
|
|
521
525
|
navigator.clipboard.writeText(text);
|
|
526
|
+
interactionClicked(lastCallId, "copy");
|
|
522
527
|
}
|
|
523
528
|
const scrollToBottom = () => {
|
|
524
529
|
var _a;
|
|
@@ -695,6 +700,7 @@ var ChatPanel = ({
|
|
|
695
700
|
};
|
|
696
701
|
const handleSuggestionClick = (suggestion) => {
|
|
697
702
|
continueChat(suggestion);
|
|
703
|
+
interactionClicked(lastCallId, "suggestion");
|
|
698
704
|
};
|
|
699
705
|
const sendConversationsViaEmail = (to, subject = `Conversation History from ${title}`, from = "") => {
|
|
700
706
|
fetch(`${publicAPIUrl}/share/email`, {
|
|
@@ -713,6 +719,7 @@ var ChatPanel = ({
|
|
|
713
719
|
title
|
|
714
720
|
})
|
|
715
721
|
});
|
|
722
|
+
interactionClicked(lastCallId, "email", from);
|
|
716
723
|
};
|
|
717
724
|
const sendCallToActionEmail = (from) => __async(void 0, null, function* () {
|
|
718
725
|
const r = yield fetch(`${publicAPIUrl}/share/email`, {
|
|
@@ -734,33 +741,24 @@ var ChatPanel = ({
|
|
|
734
741
|
if (r.ok) {
|
|
735
742
|
setHasSentCallToActionEmail(true);
|
|
736
743
|
}
|
|
744
|
+
interactionClicked(lastCallId, "cta", from);
|
|
737
745
|
});
|
|
738
|
-
const
|
|
739
|
-
console.log(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
headers: {
|
|
743
|
-
"Content-Type": "application/json"
|
|
744
|
-
},
|
|
745
|
-
body: JSON.stringify({
|
|
746
|
-
comment: "",
|
|
747
|
-
project_id: project_id != null ? project_id : ""
|
|
748
|
-
})
|
|
749
|
-
});
|
|
750
|
-
};
|
|
751
|
-
const defaultThumbsDownClick = (callId) => {
|
|
752
|
-
console.log("thumbs down", callId);
|
|
753
|
-
fetch(`${publicAPIUrl}/feedback/${callId}/thumbsdown`, {
|
|
746
|
+
const interactionClicked = (callId, action, emailaddress = "", comment = "") => __async(void 0, null, function* () {
|
|
747
|
+
console.log(`Interaction clicked: ${action} for callId: ${callId}`);
|
|
748
|
+
if (!callId || callId === "") return;
|
|
749
|
+
fetch(`${publicAPIUrl}/feedback/${callId}/${action}`, {
|
|
754
750
|
method: "POST",
|
|
755
751
|
headers: {
|
|
756
752
|
"Content-Type": "application/json"
|
|
757
753
|
},
|
|
758
754
|
body: JSON.stringify({
|
|
759
|
-
|
|
760
|
-
|
|
755
|
+
project_id: project_id != null ? project_id : "",
|
|
756
|
+
conversation_id: currentConversation != null ? currentConversation : "",
|
|
757
|
+
emailaddress,
|
|
758
|
+
comment
|
|
761
759
|
})
|
|
762
760
|
});
|
|
763
|
-
};
|
|
761
|
+
});
|
|
764
762
|
const formatPromptForDisplay = (prompt) => {
|
|
765
763
|
if (!prompt) {
|
|
766
764
|
return "";
|
|
@@ -807,7 +805,10 @@ var ChatPanel = ({
|
|
|
807
805
|
"button",
|
|
808
806
|
{
|
|
809
807
|
className: "copy-button",
|
|
810
|
-
onClick: () =>
|
|
808
|
+
onClick: () => {
|
|
809
|
+
copyToClipboard(response2.content);
|
|
810
|
+
interactionClicked(response2.callId, "copy");
|
|
811
|
+
}
|
|
811
812
|
},
|
|
812
813
|
/* @__PURE__ */ React3.createElement(
|
|
813
814
|
"svg",
|
|
@@ -836,7 +837,10 @@ var ChatPanel = ({
|
|
|
836
837
|
"button",
|
|
837
838
|
{
|
|
838
839
|
className: "thumbs-button",
|
|
839
|
-
onClick: () =>
|
|
840
|
+
onClick: () => {
|
|
841
|
+
if (thumbsUpClick) thumbsUpClick(response2.callId);
|
|
842
|
+
interactionClicked(response2.callId, "thumbsup");
|
|
843
|
+
}
|
|
840
844
|
},
|
|
841
845
|
/* @__PURE__ */ React3.createElement(
|
|
842
846
|
"svg",
|
|
@@ -852,7 +856,10 @@ var ChatPanel = ({
|
|
|
852
856
|
"button",
|
|
853
857
|
{
|
|
854
858
|
className: "thumbs-button",
|
|
855
|
-
onClick: () =>
|
|
859
|
+
onClick: () => {
|
|
860
|
+
if (thumbsDownClick) thumbsDownClick(response2.callId);
|
|
861
|
+
interactionClicked(response2.callId, "thumbsdown");
|
|
862
|
+
}
|
|
856
863
|
},
|
|
857
864
|
/* @__PURE__ */ React3.createElement(
|
|
858
865
|
"svg",
|
|
@@ -878,10 +885,13 @@ var ChatPanel = ({
|
|
|
878
885
|
"button",
|
|
879
886
|
{
|
|
880
887
|
className: "save-button",
|
|
881
|
-
onClick: () =>
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
888
|
+
onClick: () => {
|
|
889
|
+
saveHTMLToFile(
|
|
890
|
+
convertHistoryToHTML(history),
|
|
891
|
+
`conversation-${(/* @__PURE__ */ new Date()).toISOString()}.html`
|
|
892
|
+
);
|
|
893
|
+
interactionClicked(lastCallId, "save");
|
|
894
|
+
}
|
|
885
895
|
},
|
|
886
896
|
"Save Conversation"
|
|
887
897
|
), showEmailButton && /* @__PURE__ */ React3.createElement(
|
package/package.json
CHANGED
package/src/ChatPanel.tsx
CHANGED
|
@@ -147,6 +147,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
147
147
|
|
|
148
148
|
const handleSendEmail = (to: string, from: string) => {
|
|
149
149
|
sendConversationsViaEmail(to, `Conversation History from ${title}`, from);
|
|
150
|
+
interactionClicked(lastCallId, "email", to);
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
const responseAreaRef = useRef(null);
|
|
@@ -292,6 +293,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
292
293
|
try {
|
|
293
294
|
const func = new Function("match", action.clickCode);
|
|
294
295
|
func(match);
|
|
296
|
+
interactionClicked(lastCallId, "action");
|
|
295
297
|
} catch (error) {
|
|
296
298
|
console.error("Error executing clickCode:", error);
|
|
297
299
|
}
|
|
@@ -325,23 +327,25 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
325
327
|
if (initialPrompt !== lastPrompt) {
|
|
326
328
|
setIsLoading(true);
|
|
327
329
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
330
|
+
ensureConversation().then((convId) => {
|
|
331
|
+
if (lastController) stop(lastController);
|
|
332
|
+
const controller = new AbortController();
|
|
333
|
+
|
|
334
|
+
send(
|
|
335
|
+
initialPrompt,
|
|
336
|
+
messages,
|
|
337
|
+
data,
|
|
338
|
+
true,
|
|
339
|
+
true,
|
|
340
|
+
service,
|
|
341
|
+
convId,
|
|
342
|
+
controller
|
|
343
|
+
);
|
|
344
|
+
setLastPrompt(initialPrompt);
|
|
345
|
+
setLastKey(initialPrompt);
|
|
346
|
+
setLastController(controller);
|
|
347
|
+
setHistory({});
|
|
348
|
+
});
|
|
345
349
|
}
|
|
346
350
|
}
|
|
347
351
|
}, [initialPrompt]);
|
|
@@ -388,44 +392,44 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
388
392
|
}
|
|
389
393
|
}, [followOnPrompt]);
|
|
390
394
|
|
|
395
|
+
const ensureConversation = () => {
|
|
396
|
+
if (
|
|
397
|
+
(!currentConversation || currentConversation === "") &&
|
|
398
|
+
createConversationOnFirstChat
|
|
399
|
+
) {
|
|
400
|
+
return fetch(`${publicAPIUrl}/conversations`, {
|
|
401
|
+
method: "POST",
|
|
402
|
+
headers: {
|
|
403
|
+
"Content-Type": "application/json",
|
|
404
|
+
},
|
|
405
|
+
body: JSON.stringify({
|
|
406
|
+
project_id: project_id ?? "",
|
|
407
|
+
agentId: agent,
|
|
408
|
+
customerId: customer?.customer_id ?? null,
|
|
409
|
+
customerEmail: customer?.customer_name ?? null,
|
|
410
|
+
}),
|
|
411
|
+
})
|
|
412
|
+
.then((res) => res.json())
|
|
413
|
+
.then((newConvo) => {
|
|
414
|
+
if (newConvo?.id) {
|
|
415
|
+
console.log("new conversation created", newConvo.id);
|
|
416
|
+
setCurrentConversation(newConvo.id);
|
|
417
|
+
return newConvo.id;
|
|
418
|
+
}
|
|
419
|
+
return "";
|
|
420
|
+
})
|
|
421
|
+
.catch((error) => {
|
|
422
|
+
console.error("Error creating new conversation", error);
|
|
423
|
+
return "";
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
// If a currentConversation exists, return it in a resolved Promise.
|
|
427
|
+
return Promise.resolve(currentConversation);
|
|
428
|
+
};
|
|
429
|
+
|
|
391
430
|
const continueChat = (suggestion?: string) => {
|
|
392
431
|
console.log("continueChat", suggestion);
|
|
393
432
|
|
|
394
|
-
const ensureConversation = () => {
|
|
395
|
-
if (
|
|
396
|
-
(!currentConversation || currentConversation === "") &&
|
|
397
|
-
createConversationOnFirstChat
|
|
398
|
-
) {
|
|
399
|
-
return fetch(`${publicAPIUrl}/conversations`, {
|
|
400
|
-
method: "POST",
|
|
401
|
-
headers: {
|
|
402
|
-
"Content-Type": "application/json",
|
|
403
|
-
},
|
|
404
|
-
body: JSON.stringify({
|
|
405
|
-
project_id: project_id ?? "",
|
|
406
|
-
agentId: agent,
|
|
407
|
-
customerId: customer?.customer_id ?? null,
|
|
408
|
-
customerEmail: customer?.customer_name ?? null,
|
|
409
|
-
}),
|
|
410
|
-
})
|
|
411
|
-
.then((res) => res.json())
|
|
412
|
-
.then((newConvo) => {
|
|
413
|
-
if (newConvo?.id) {
|
|
414
|
-
console.log("new conversation created", newConvo.id);
|
|
415
|
-
setCurrentConversation(newConvo.id);
|
|
416
|
-
return newConvo.id;
|
|
417
|
-
}
|
|
418
|
-
return "";
|
|
419
|
-
})
|
|
420
|
-
.catch((error) => {
|
|
421
|
-
console.error("Error creating new conversation", error);
|
|
422
|
-
return "";
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
// If a currentConversation exists, return it in a resolved Promise.
|
|
426
|
-
return Promise.resolve(currentConversation);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
433
|
// wait till new conversation created....
|
|
430
434
|
ensureConversation().then((convId) => {
|
|
431
435
|
if (!idle) {
|
|
@@ -558,6 +562,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
558
562
|
|
|
559
563
|
function copyToClipboard(text: string) {
|
|
560
564
|
navigator.clipboard.writeText(text);
|
|
565
|
+
interactionClicked(lastCallId, "copy");
|
|
561
566
|
}
|
|
562
567
|
|
|
563
568
|
const scrollToBottom = () => {
|
|
@@ -749,6 +754,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
749
754
|
|
|
750
755
|
const handleSuggestionClick = (suggestion: string) => {
|
|
751
756
|
continueChat(suggestion);
|
|
757
|
+
interactionClicked(lastCallId, "suggestion");
|
|
752
758
|
};
|
|
753
759
|
|
|
754
760
|
const sendConversationsViaEmail = (
|
|
@@ -772,6 +778,8 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
772
778
|
title: title,
|
|
773
779
|
}),
|
|
774
780
|
});
|
|
781
|
+
|
|
782
|
+
interactionClicked(lastCallId, "email", from);
|
|
775
783
|
};
|
|
776
784
|
|
|
777
785
|
const sendCallToActionEmail = async (from: string) => {
|
|
@@ -795,32 +803,30 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
795
803
|
if (r.ok) {
|
|
796
804
|
setHasSentCallToActionEmail(true);
|
|
797
805
|
}
|
|
798
|
-
};
|
|
799
806
|
|
|
800
|
-
|
|
801
|
-
console.log("thumbs up", callId);
|
|
802
|
-
fetch(`${publicAPIUrl}/feedback/${callId}/thumbsup`, {
|
|
803
|
-
method: "POST",
|
|
804
|
-
headers: {
|
|
805
|
-
"Content-Type": "application/json",
|
|
806
|
-
},
|
|
807
|
-
body: JSON.stringify({
|
|
808
|
-
comment: "",
|
|
809
|
-
project_id: project_id ?? "",
|
|
810
|
-
}),
|
|
811
|
-
});
|
|
807
|
+
interactionClicked(lastCallId, "cta", from);
|
|
812
808
|
};
|
|
813
809
|
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
|
|
810
|
+
const interactionClicked = async (
|
|
811
|
+
callId: string,
|
|
812
|
+
action: string,
|
|
813
|
+
emailaddress: string = "",
|
|
814
|
+
comment: string = ""
|
|
815
|
+
) => {
|
|
816
|
+
console.log(`Interaction clicked: ${action} for callId: ${callId}`);
|
|
817
|
+
|
|
818
|
+
if (!callId || callId === "") return;
|
|
819
|
+
|
|
820
|
+
fetch(`${publicAPIUrl}/feedback/${callId}/${action}`, {
|
|
817
821
|
method: "POST",
|
|
818
822
|
headers: {
|
|
819
823
|
"Content-Type": "application/json",
|
|
820
824
|
},
|
|
821
825
|
body: JSON.stringify({
|
|
822
|
-
comment: "",
|
|
823
826
|
project_id: project_id ?? "",
|
|
827
|
+
conversation_id: currentConversation ?? "",
|
|
828
|
+
emailaddress: emailaddress,
|
|
829
|
+
comment: comment,
|
|
824
830
|
}),
|
|
825
831
|
});
|
|
826
832
|
};
|
|
@@ -891,7 +897,10 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
891
897
|
<div className="button-container">
|
|
892
898
|
<button
|
|
893
899
|
className="copy-button"
|
|
894
|
-
onClick={() =>
|
|
900
|
+
onClick={() => {
|
|
901
|
+
copyToClipboard(response.content);
|
|
902
|
+
interactionClicked(response.callId, "copy");
|
|
903
|
+
}}
|
|
895
904
|
>
|
|
896
905
|
<svg
|
|
897
906
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -915,11 +924,10 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
915
924
|
|
|
916
925
|
<button
|
|
917
926
|
className="thumbs-button"
|
|
918
|
-
onClick={() =>
|
|
919
|
-
thumbsUpClick
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
}
|
|
927
|
+
onClick={() => {
|
|
928
|
+
if (thumbsUpClick) thumbsUpClick(response.callId);
|
|
929
|
+
interactionClicked(response.callId, "thumbsup");
|
|
930
|
+
}}
|
|
923
931
|
>
|
|
924
932
|
<svg
|
|
925
933
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -933,11 +941,10 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
933
941
|
|
|
934
942
|
<button
|
|
935
943
|
className="thumbs-button"
|
|
936
|
-
onClick={() =>
|
|
937
|
-
thumbsDownClick
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
}
|
|
944
|
+
onClick={() => {
|
|
945
|
+
if (thumbsDownClick) thumbsDownClick(response.callId);
|
|
946
|
+
interactionClicked(response.callId, "thumbsdown");
|
|
947
|
+
}}
|
|
941
948
|
>
|
|
942
949
|
<svg
|
|
943
950
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -980,12 +987,13 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
980
987
|
{showSaveButton && (
|
|
981
988
|
<button
|
|
982
989
|
className="save-button"
|
|
983
|
-
onClick={() =>
|
|
990
|
+
onClick={() => {
|
|
984
991
|
saveHTMLToFile(
|
|
985
992
|
convertHistoryToHTML(history),
|
|
986
993
|
`conversation-${new Date().toISOString()}.html`
|
|
987
|
-
)
|
|
988
|
-
|
|
994
|
+
);
|
|
995
|
+
interactionClicked(lastCallId, "save");
|
|
996
|
+
}}
|
|
989
997
|
>
|
|
990
998
|
Save Conversation
|
|
991
999
|
</button>
|