@promptbook/components 0.112.0-28 → 0.112.0-30
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/esm/index.es.js +62 -22
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +2 -0
- package/esm/src/_packages/types.index.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +83 -0
- package/esm/src/book-components/Chat/Chat/ChatRatingModal.d.ts +5 -1
- package/esm/src/book-components/Chat/hooks/useChatRatings.d.ts +5 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +62 -22
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +2 -0
- package/umd/src/_packages/types.index.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +83 -0
- package/umd/src/book-components/Chat/Chat/ChatRatingModal.d.ts +5 -1
- package/umd/src/book-components/Chat/hooks/useChatRatings.d.ts +5 -1
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -39,7 +39,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
39
39
|
* @generated
|
|
40
40
|
* @see https://github.com/webgptorg/promptbook
|
|
41
41
|
*/
|
|
42
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
42
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-30';
|
|
43
43
|
/**
|
|
44
44
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
45
45
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11369,7 +11369,11 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11369
11369
|
*
|
|
11370
11370
|
* @private internal constant for `aggregateUseCommitmentSystemMessages`
|
|
11371
11371
|
*/
|
|
11372
|
-
const AGGREGATED_USE_COMMITMENT_TYPES = [
|
|
11372
|
+
const AGGREGATED_USE_COMMITMENT_TYPES = [
|
|
11373
|
+
'USE BROWSER',
|
|
11374
|
+
'USE SEARCH ENGINE',
|
|
11375
|
+
'USE TIME',
|
|
11376
|
+
];
|
|
11373
11377
|
/**
|
|
11374
11378
|
* Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
|
|
11375
11379
|
*
|
|
@@ -21675,7 +21679,7 @@ const DEFAULT_FEEDBACK_ERROR_MESSAGE = 'Failed to save feedback. Please try agai
|
|
|
21675
21679
|
* @private component of `<Chat/>`
|
|
21676
21680
|
*/
|
|
21677
21681
|
function useChatRatings(options) {
|
|
21678
|
-
const { messages, onFeedback, feedbackMode, isMobile } = options;
|
|
21682
|
+
const { messages, onFeedback, feedbackMode, feedbackTranslations, isMobile } = options;
|
|
21679
21683
|
const [ratingModalOpen, setRatingModalOpen] = useState(false);
|
|
21680
21684
|
const [selectedMessage, setSelectedMessage] = useState(null);
|
|
21681
21685
|
const [messageRatings, setMessageRatings] = useState(new Map());
|
|
@@ -21718,7 +21722,7 @@ function useChatRatings(options) {
|
|
|
21718
21722
|
};
|
|
21719
21723
|
}, []);
|
|
21720
21724
|
const submitRating = useCallback(async () => {
|
|
21721
|
-
var _a;
|
|
21725
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21722
21726
|
if (!selectedMessage) {
|
|
21723
21727
|
return;
|
|
21724
21728
|
}
|
|
@@ -21742,14 +21746,16 @@ function useChatRatings(options) {
|
|
|
21742
21746
|
const feedbackResponse = await onFeedback(feedbackData);
|
|
21743
21747
|
showFeedbackStatus({
|
|
21744
21748
|
message: (_a = feedbackResponse === null || feedbackResponse === void 0 ? void 0 : feedbackResponse.message) !== null && _a !== void 0 ? _a : (feedbackMode === 'report_issue'
|
|
21745
|
-
? DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE
|
|
21746
|
-
: DEFAULT_FEEDBACK_SUCCESS_MESSAGE),
|
|
21749
|
+
? (_b = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSuccessMessage) !== null && _b !== void 0 ? _b : DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE
|
|
21750
|
+
: (_c = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackSuccessMessage) !== null && _c !== void 0 ? _c : DEFAULT_FEEDBACK_SUCCESS_MESSAGE),
|
|
21747
21751
|
variant: 'success',
|
|
21748
21752
|
});
|
|
21749
21753
|
}
|
|
21750
21754
|
catch (error) {
|
|
21751
21755
|
console.error('Error submitting feedback:', error);
|
|
21752
|
-
const message = error instanceof Error
|
|
21756
|
+
const message = error instanceof Error
|
|
21757
|
+
? error.message
|
|
21758
|
+
: (_d = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackErrorMessage) !== null && _d !== void 0 ? _d : DEFAULT_FEEDBACK_ERROR_MESSAGE;
|
|
21753
21759
|
showFeedbackStatus({ message, variant: 'error' });
|
|
21754
21760
|
return;
|
|
21755
21761
|
}
|
|
@@ -21764,15 +21770,26 @@ function useChatRatings(options) {
|
|
|
21764
21770
|
});
|
|
21765
21771
|
showFeedbackStatus({
|
|
21766
21772
|
message: feedbackMode === 'report_issue'
|
|
21767
|
-
? DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE
|
|
21768
|
-
: DEFAULT_FEEDBACK_SUCCESS_MESSAGE,
|
|
21773
|
+
? (_e = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSuccessMessage) !== null && _e !== void 0 ? _e : DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE
|
|
21774
|
+
: (_f = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackSuccessMessage) !== null && _f !== void 0 ? _f : DEFAULT_FEEDBACK_SUCCESS_MESSAGE,
|
|
21769
21775
|
variant: 'success',
|
|
21770
21776
|
});
|
|
21771
21777
|
}
|
|
21772
21778
|
setRatingModalOpen(false);
|
|
21773
21779
|
setTextRating('');
|
|
21774
21780
|
setSelectedMessage(null);
|
|
21775
|
-
}, [
|
|
21781
|
+
}, [
|
|
21782
|
+
feedbackMode,
|
|
21783
|
+
feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackErrorMessage,
|
|
21784
|
+
feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackSuccessMessage,
|
|
21785
|
+
feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSuccessMessage,
|
|
21786
|
+
messages,
|
|
21787
|
+
messageRatings,
|
|
21788
|
+
onFeedback,
|
|
21789
|
+
selectedMessage,
|
|
21790
|
+
showFeedbackStatus,
|
|
21791
|
+
textRating,
|
|
21792
|
+
]);
|
|
21776
21793
|
useEffect(() => {
|
|
21777
21794
|
if (ratingModalOpen && isMobile) {
|
|
21778
21795
|
document.body.style.overflow = 'hidden';
|
|
@@ -40288,7 +40305,7 @@ const ChatMessageItem = memo(
|
|
|
40288
40305
|
// Or make normal function from this?
|
|
40289
40306
|
(props) => {
|
|
40290
40307
|
var _a;
|
|
40291
|
-
const { message, participant, participants, isLastMessage, onMessage, onActionButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', onCopy, onCreateAgent, teammates, teamAgentProfiles, onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, } = props;
|
|
40308
|
+
const { message, participant, participants, isLastMessage, onMessage, onActionButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, onCopy, onCreateAgent, teammates, teamAgentProfiles, onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, } = props;
|
|
40292
40309
|
const { isComplete = true,
|
|
40293
40310
|
// <- TODO: Destruct all `messages` properties like `isComplete`
|
|
40294
40311
|
} = message;
|
|
@@ -40707,7 +40724,8 @@ const ChatMessageItem = memo(
|
|
|
40707
40724
|
: () => {
|
|
40708
40725
|
setExpandedMessageId(null);
|
|
40709
40726
|
setLocalHoveredRating(0);
|
|
40710
|
-
}, children: isReportIssueFeedbackMode ? (jsx("button", { type: "button", onClick: () => handleRating(message, 1), className: styles$5.feedbackIssueButton, "aria-label":
|
|
40727
|
+
}, children: isReportIssueFeedbackMode ? (jsx("button", { type: "button", onClick: () => handleRating(message, 1), className: styles$5.feedbackIssueButton, "aria-label": (feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueButtonAriaLabel) ||
|
|
40728
|
+
'Report issue with this response', title: (feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueButtonTitle) || 'Report issue', children: "\u26A0" })) : isExpanded ? ([1, 2, 3, 4, 5].map((star) => (jsx("span", { onClick: () => handleRating(message, star), onMouseEnter: () => setLocalHoveredRating(star), className: classNames(styles$5.ratingStar, star <= (localHoveredRating || currentRating || 0) && styles$5.active), style: {
|
|
40711
40729
|
'--star-inactive-color': mode === 'LIGHT' ? '#ccc' : '#555',
|
|
40712
40730
|
}, children: "\u2B50" }, star)))) : (jsx("span", { onClick: () => handleRating(message, currentRating || 1), className: classNames(styles$5.ratingStar, currentRating && styles$5.active), style: {
|
|
40713
40731
|
'--star-inactive-color': mode === 'LIGHT' ? '#888' : '#666',
|
|
@@ -40789,6 +40807,9 @@ const ChatMessageItem = memo(
|
|
|
40789
40807
|
if (prev.feedbackMode !== next.feedbackMode) {
|
|
40790
40808
|
return false;
|
|
40791
40809
|
}
|
|
40810
|
+
if (prev.feedbackTranslations !== next.feedbackTranslations) {
|
|
40811
|
+
return false;
|
|
40812
|
+
}
|
|
40792
40813
|
if (prev.handleRating !== next.handleRating) {
|
|
40793
40814
|
return false;
|
|
40794
40815
|
}
|
|
@@ -40814,7 +40835,7 @@ ChatMessageItem.displayName = 'ChatMessageItem';
|
|
|
40814
40835
|
* @private component of `<Chat/>`
|
|
40815
40836
|
*/
|
|
40816
40837
|
function ChatMessageList(props) {
|
|
40817
|
-
const { messages, participants, expandedMessageId, messageRatings, setExpandedMessageId, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode, onCopy, onMessage, onActionButton, onCreateAgent, toolTitles, teammates, onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, teamAgentProfiles, setChatMessagesElement, onScroll, chatMessagesClassName, hasActions, } = props;
|
|
40838
|
+
const { messages, participants, expandedMessageId, messageRatings, setExpandedMessageId, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode, feedbackTranslations, onCopy, onMessage, onActionButton, onCreateAgent, toolTitles, teammates, onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, teamAgentProfiles, setChatMessagesElement, onScroll, chatMessagesClassName, hasActions, } = props;
|
|
40818
40839
|
const firstMessage = messages[0];
|
|
40819
40840
|
const firstMsgContent = (firstMessage === null || firstMessage === void 0 ? void 0 : firstMessage.content) || '';
|
|
40820
40841
|
const firstMsgLines = firstMsgContent.split(/\r?\n/).length;
|
|
@@ -40826,7 +40847,7 @@ function ChatMessageList(props) {
|
|
|
40826
40847
|
const isLastMessage = index === messages.length - 1;
|
|
40827
40848
|
const isExpanded = expandedMessageId === message.id;
|
|
40828
40849
|
const currentRating = messageRatings.get(message.id || message.content /* <-[??] */) || 0;
|
|
40829
|
-
return (jsx(ChatMessageItem, { message: message, participant: participant, participants: participants, isLastMessage: isLastMessage, onMessage: onMessage, onActionButton: onActionButton, setExpandedMessageId: setExpandedMessageId, isExpanded: isExpanded, currentRating: currentRating, handleRating: handleRating, mode: mode, isCopyButtonEnabled: isCopyButtonEnabled, isFeedbackEnabled: isFeedbackEnabled, feedbackMode: feedbackMode, onCopy: onCopy, onCreateAgent: onCreateAgent, toolTitles: toolTitles, teammates: teammates, teamAgentProfiles: teamAgentProfiles, onToolCallClick: onToolCallClick, onCitationClick: onCitationClick, soundSystem: soundSystem, isSpeechPlaybackEnabled: isSpeechPlaybackEnabled, elevenLabsVoiceId: elevenLabsVoiceId }, resolveRenderedMessageKey(message)));
|
|
40850
|
+
return (jsx(ChatMessageItem, { message: message, participant: participant, participants: participants, isLastMessage: isLastMessage, onMessage: onMessage, onActionButton: onActionButton, setExpandedMessageId: setExpandedMessageId, isExpanded: isExpanded, currentRating: currentRating, handleRating: handleRating, mode: mode, isCopyButtonEnabled: isCopyButtonEnabled, isFeedbackEnabled: isFeedbackEnabled, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, onCopy: onCopy, onCreateAgent: onCreateAgent, toolTitles: toolTitles, teammates: teammates, teamAgentProfiles: teamAgentProfiles, onToolCallClick: onToolCallClick, onCitationClick: onCitationClick, soundSystem: soundSystem, isSpeechPlaybackEnabled: isSpeechPlaybackEnabled, elevenLabsVoiceId: elevenLabsVoiceId }, resolveRenderedMessageKey(message)));
|
|
40830
40851
|
}), jsx("div", { style: { height: 100 } })] }));
|
|
40831
40852
|
}
|
|
40832
40853
|
/**
|
|
@@ -40851,7 +40872,8 @@ function resolveRenderedMessageKey(message) {
|
|
|
40851
40872
|
* @private component of `<Chat/>`
|
|
40852
40873
|
*/
|
|
40853
40874
|
function ChatRatingModal(props) {
|
|
40854
|
-
|
|
40875
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
40876
|
+
const { isOpen, selectedMessage, postprocessedMessages, messages, hoveredRating, messageRatings, textRating, feedbackMode, feedbackTranslations, mode, isMobile, onClose, setHoveredRating, setMessageRatings, setSelectedMessage, setTextRating, submitRating, } = props;
|
|
40855
40877
|
if (!isOpen || !selectedMessage) {
|
|
40856
40878
|
return null;
|
|
40857
40879
|
}
|
|
@@ -40876,7 +40898,9 @@ function ChatRatingModal(props) {
|
|
|
40876
40898
|
if (event.target === event.currentTarget && isMobile) {
|
|
40877
40899
|
onClose();
|
|
40878
40900
|
}
|
|
40879
|
-
}, children: jsxs("div", { className: styles$5.ratingModalContent, children: [jsx("h3", { children: isReportIssueMode
|
|
40901
|
+
}, children: jsxs("div", { className: styles$5.ratingModalContent, children: [jsx("h3", { children: isReportIssueMode
|
|
40902
|
+
? (_a = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueModalTitle) !== null && _a !== void 0 ? _a : 'Report issue'
|
|
40903
|
+
: (_b = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.rateResponseModalTitle) !== null && _b !== void 0 ? _b : 'Rate this response' }), !isReportIssueMode && (jsx("div", { className: styles$5.stars, children: [1, 2, 3, 4, 5].map((star) => (jsx("span", { onClick: () => setMessageRatings((previousRatings) => {
|
|
40880
40904
|
const nextRatings = new Map(previousRatings);
|
|
40881
40905
|
nextRatings.set(selectedMessage.id || selectedMessage.content /* <-[??] */, star);
|
|
40882
40906
|
return nextRatings;
|
|
@@ -40889,11 +40913,21 @@ function ChatRatingModal(props) {
|
|
|
40889
40913
|
: mode === 'LIGHT'
|
|
40890
40914
|
? '#ccc'
|
|
40891
40915
|
: '#555',
|
|
40892
|
-
}, children: "\u2B50" }, star))) })),
|
|
40916
|
+
}, children: "\u2B50" }, star))) })), (_c = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.userQuestionLabel) !== null && _c !== void 0 ? _c : 'Your question:', jsx("textarea", { readOnly: true, value: userQuestion, className: styles$5.ratingInput }), isReportIssueMode
|
|
40917
|
+
? (_d = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueExpectedAnswerLabel) !== null && _d !== void 0 ? _d : 'What should the answer include?'
|
|
40918
|
+
: (_e = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.expectedAnswerLabel) !== null && _e !== void 0 ? _e : 'Expected answer:', jsx("textarea", { placeholder: selectedMessage.content ||
|
|
40919
|
+
(feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.expectedAnswerPlaceholder) ||
|
|
40920
|
+
'Expected answer (optional)', defaultValue: selectedMessage.expectedAnswer || selectedMessage.content, onChange: (event) => {
|
|
40893
40921
|
if (selectedMessage) {
|
|
40894
40922
|
setSelectedMessage({ ...selectedMessage, expectedAnswer: event.target.value });
|
|
40895
40923
|
}
|
|
40896
|
-
}, className: styles$5.ratingInput }), isReportIssueMode
|
|
40924
|
+
}, className: styles$5.ratingInput }), isReportIssueMode
|
|
40925
|
+
? (_f = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueDetailsLabel) !== null && _f !== void 0 ? _f : 'Issue details:'
|
|
40926
|
+
: (_g = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.noteLabel) !== null && _g !== void 0 ? _g : 'Note:', jsx("textarea", { placeholder: isReportIssueMode
|
|
40927
|
+
? (_h = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueDetailsPlaceholder) !== null && _h !== void 0 ? _h : 'Describe what went wrong (optional)'
|
|
40928
|
+
: (_j = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.notePlaceholder) !== null && _j !== void 0 ? _j : 'Add a note (optional)', defaultValue: textRating, onChange: (event) => setTextRating(event.target.value), className: styles$5.ratingInput }), jsxs("div", { className: styles$5.ratingActions, children: [jsx("button", { onClick: onClose, children: (feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.cancelLabel) || 'Cancel' }), jsx("button", { onClick: submitRating, children: isReportIssueMode
|
|
40929
|
+
? (_k = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSubmitLabel) !== null && _k !== void 0 ? _k : 'Report issue'
|
|
40930
|
+
: (_l = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.submitLabel) !== null && _l !== void 0 ? _l : 'Submit' })] })] }) }));
|
|
40897
40931
|
}
|
|
40898
40932
|
|
|
40899
40933
|
/**
|
|
@@ -42853,7 +42887,7 @@ function isLatestMessageVisible(chatMessagesElement, messageSelector) {
|
|
|
42853
42887
|
* @public exported from `@promptbook/components`
|
|
42854
42888
|
*/
|
|
42855
42889
|
function Chat(props) {
|
|
42856
|
-
const { title = 'Chat', messages, onChange, onMessage, onActionButton, onReset, resetRequiresConfirmation = true, onFeedback, feedbackMode = 'stars', onFileUpload, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, } = props;
|
|
42890
|
+
const { title = 'Chat', messages, onChange, onMessage, onActionButton, onReset, resetRequiresConfirmation = true, onFeedback, feedbackMode = 'stars', feedbackTranslations, onFileUpload, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, } = props;
|
|
42857
42891
|
const buttonColor = useMemo(() => Color.from(buttonColorRaw || '#0066cc'), [buttonColorRaw]);
|
|
42858
42892
|
const agentParticipant = useMemo(() => participants.find((participant) => participant.name === 'AGENT'), [participants]);
|
|
42859
42893
|
const postprocessedMessages = useMemo(() => {
|
|
@@ -42924,7 +42958,13 @@ function Chat(props) {
|
|
|
42924
42958
|
const shouldShowScrollToBottom = !isAutoScrolling && !isLatestMessageInView;
|
|
42925
42959
|
const lastMessage = postprocessedMessages[postprocessedMessages.length - 1];
|
|
42926
42960
|
const isStreamingAgentMessage = Boolean(lastMessage && lastMessage.sender !== 'USER' && !lastMessage.isComplete);
|
|
42927
|
-
const { state: { ratingModalOpen, selectedMessage, messageRatings, textRating, hoveredRating, expandedMessageId, feedbackStatus, }, actions: { setRatingModalOpen, setSelectedMessage, setMessageRatings, setTextRating, setHoveredRating, setExpandedMessageId, handleRating, submitRating, }, } = useChatRatings({
|
|
42961
|
+
const { state: { ratingModalOpen, selectedMessage, messageRatings, textRating, hoveredRating, expandedMessageId, feedbackStatus, }, actions: { setRatingModalOpen, setSelectedMessage, setMessageRatings, setTextRating, setHoveredRating, setExpandedMessageId, handleRating, submitRating, }, } = useChatRatings({
|
|
42962
|
+
messages,
|
|
42963
|
+
onFeedback,
|
|
42964
|
+
feedbackMode,
|
|
42965
|
+
feedbackTranslations,
|
|
42966
|
+
isMobile: isMobileFromHook,
|
|
42967
|
+
});
|
|
42928
42968
|
const [toolCallModalOpen, setToolCallModalOpen] = useState(false);
|
|
42929
42969
|
const [selectedToolCallState, setSelectedToolCallState] = useState(null);
|
|
42930
42970
|
const [citationModalOpen, setCitationModalOpen] = useState(false);
|
|
@@ -43023,7 +43063,7 @@ function Chat(props) {
|
|
|
43023
43063
|
}, [postprocessedMessages, soundSystem]);
|
|
43024
43064
|
return (jsxs(Fragment, { children: [feedbackStatus && (jsx("div", { className: classNames(styles$5.feedbackStatus, feedbackStatus.variant === 'success'
|
|
43025
43065
|
? styles$5.feedbackStatusSuccess
|
|
43026
|
-
: styles$5.feedbackStatusError), "aria-live": "polite", role: "status", children: feedbackStatus.message })), effectConfigs && effectConfigs.length > 0 && (jsx(ChatEffectsSystem, { messages: postprocessedMessages, effectConfigs: effectConfigs, soundSystem: soundSystem })), jsx("div", { className: classNames(className, styles$5.Chat, visual === 'STANDALONE' && styles$5.standaloneVisual, visual === 'FULL_PAGE' && styles$5.fullPageVisual, getChatCssClassName('Chat'), chatCssClassNames.chat), style, children: jsxs("div", { className: classNames(className, styles$5.chatMainFlow, getChatCssClassName('chatMainFlow'), chatCssClassNames.chatMainFlow), children: [children && jsx("div", { className: classNames(styles$5.chatChildren), children: children }), shouldShowScrollToBottom && (jsx("div", { className: styles$5.scrollToBottomContainer, children: jsxs("div", { className: styles$5.scrollToBottomWrapper, children: [jsx(SolidArrowButton, { "data-button-type": "custom", direction: "down", iconSize: 33, className: classNames(styles$5.scrollToBottom, scrollToBottomCssClassName), onClick: handleButtonClick(scrollToBottom), "aria-label": ariaLabel, title: ariaLabel }), badgeLabel && (jsx("span", { className: styles$5.scrollToBottomBadge, "aria-live": "polite", role: "status", children: badgeLabel }))] }) })), isVoiceCalling && (jsx("div", { className: styles$5.voiceCallIndicatorBar, children: jsxs("div", { className: styles$5.voiceCallIndicator, children: [jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: jsx("path", { d: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z" }) }), jsx("span", { children: "Voice call active" }), jsx("div", { className: styles$5.voiceCallPulse })] }) })), jsx(ChatActionsBar, { actionsRef: actionsRef, actionsContainer: actionsContainer, messages: postprocessedMessages, participants: participants, title: title, onReset: onReset, resetRequiresConfirmation: resetRequiresConfirmation, onUseTemplate: onUseTemplate, extraActions: extraActions, saveFormats: saveFormats, isSaveButtonEnabled: isSaveButtonEnabled, shouldFadeActions: shouldFadeActions, shouldDisableActions: shouldDisableActions, onButtonClick: handleButtonClick }), jsx(ChatMessageList, { messages: postprocessedMessages, participants: participants, expandedMessageId: expandedMessageId, messageRatings: messageRatings, setExpandedMessageId: setExpandedMessageId, handleRating: handleRating, mode: mode, isCopyButtonEnabled: isCopyButtonEnabled, isFeedbackEnabled: isFeedbackEnabled, feedbackMode: feedbackMode, onCopy: handleCopy, onMessage: onMessage, onActionButton: onActionButton, onCreateAgent: onCreateAgent, toolTitles: toolTitles, teammates: teammates, teamAgentProfiles: teamAgentProfiles, soundSystem: soundSystem, onToolCallClick: (toolCall) => {
|
|
43066
|
+
: styles$5.feedbackStatusError), "aria-live": "polite", role: "status", children: feedbackStatus.message })), effectConfigs && effectConfigs.length > 0 && (jsx(ChatEffectsSystem, { messages: postprocessedMessages, effectConfigs: effectConfigs, soundSystem: soundSystem })), jsx("div", { className: classNames(className, styles$5.Chat, visual === 'STANDALONE' && styles$5.standaloneVisual, visual === 'FULL_PAGE' && styles$5.fullPageVisual, getChatCssClassName('Chat'), chatCssClassNames.chat), style, children: jsxs("div", { className: classNames(className, styles$5.chatMainFlow, getChatCssClassName('chatMainFlow'), chatCssClassNames.chatMainFlow), children: [children && jsx("div", { className: classNames(styles$5.chatChildren), children: children }), shouldShowScrollToBottom && (jsx("div", { className: styles$5.scrollToBottomContainer, children: jsxs("div", { className: styles$5.scrollToBottomWrapper, children: [jsx(SolidArrowButton, { "data-button-type": "custom", direction: "down", iconSize: 33, className: classNames(styles$5.scrollToBottom, scrollToBottomCssClassName), onClick: handleButtonClick(scrollToBottom), "aria-label": ariaLabel, title: ariaLabel }), badgeLabel && (jsx("span", { className: styles$5.scrollToBottomBadge, "aria-live": "polite", role: "status", children: badgeLabel }))] }) })), isVoiceCalling && (jsx("div", { className: styles$5.voiceCallIndicatorBar, children: jsxs("div", { className: styles$5.voiceCallIndicator, children: [jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: jsx("path", { d: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z" }) }), jsx("span", { children: "Voice call active" }), jsx("div", { className: styles$5.voiceCallPulse })] }) })), jsx(ChatActionsBar, { actionsRef: actionsRef, actionsContainer: actionsContainer, messages: postprocessedMessages, participants: participants, title: title, onReset: onReset, resetRequiresConfirmation: resetRequiresConfirmation, onUseTemplate: onUseTemplate, extraActions: extraActions, saveFormats: saveFormats, isSaveButtonEnabled: isSaveButtonEnabled, shouldFadeActions: shouldFadeActions, shouldDisableActions: shouldDisableActions, onButtonClick: handleButtonClick }), jsx(ChatMessageList, { messages: postprocessedMessages, participants: participants, expandedMessageId: expandedMessageId, messageRatings: messageRatings, setExpandedMessageId: setExpandedMessageId, handleRating: handleRating, mode: mode, isCopyButtonEnabled: isCopyButtonEnabled, isFeedbackEnabled: isFeedbackEnabled, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, onCopy: handleCopy, onMessage: onMessage, onActionButton: onActionButton, onCreateAgent: onCreateAgent, toolTitles: toolTitles, teammates: teammates, teamAgentProfiles: teamAgentProfiles, soundSystem: soundSystem, onToolCallClick: (toolCall) => {
|
|
43027
43067
|
setSelectedToolCallState({
|
|
43028
43068
|
identity: getToolCallIdentity(toolCall),
|
|
43029
43069
|
fallbackToolCall: toolCall,
|
|
@@ -43035,7 +43075,7 @@ function Chat(props) {
|
|
|
43035
43075
|
}, setChatMessagesElement: setChatMessagesElement, onScroll: handleChatScroll, isSpeechPlaybackEnabled: isSpeechPlaybackEnabled, elevenLabsVoiceId: elevenLabsVoiceId, chatMessagesClassName: classNames(getChatCssClassName('chatMessages'), chatCssClassNames.chatMessages), hasActions: hasActions }), onMessage && (jsx(ChatInputArea, { onMessage: onMessage, onChange: onChange, onFileUpload: onFileUpload, speechRecognition: speechRecognition, speechRecognitionLanguage: speechRecognitionLanguage, defaultMessage: defaultMessage, enterBehavior: enterBehavior, resolveEnterBehavior: resolveEnterBehavior, placeholderMessageContent: placeholderMessageContent, isFocusedOnLoad: isFocusedOnLoad, isMobile: isMobileFromHook, isVoiceCalling: isVoiceCalling, participants: participants, buttonColor: buttonColor, soundSystem: soundSystem, onButtonClick: handleButtonClick, chatInputClassName: classNames(getChatCssClassName('chatInput'), chatCssClassNames.chatInput) }))] }) }), jsx(ChatToolCallModal, { isOpen: toolCallModalOpen, toolCall: selectedToolCall, toolCallIdentity: (selectedToolCallState === null || selectedToolCallState === void 0 ? void 0 : selectedToolCallState.identity) || null, onClose: () => {
|
|
43036
43076
|
setToolCallModalOpen(false);
|
|
43037
43077
|
setSelectedToolCallState(null);
|
|
43038
|
-
}, toolTitles: toolTitles, agentParticipant: agentParticipant, buttonColor: buttonColor, teamAgentProfiles: teamAgentProfiles }), jsx(ChatCitationModal, { isOpen: citationModalOpen, citation: selectedCitation, participants: participants, soundSystem: soundSystem, onClose: () => setCitationModalOpen(false) }), jsx(ChatRatingModal, { isOpen: ratingModalOpen, selectedMessage: selectedMessage, postprocessedMessages: postprocessedMessages, messages: messages, hoveredRating: hoveredRating, messageRatings: messageRatings, textRating: textRating, feedbackMode: feedbackMode, mode: mode, isMobile: isMobileFromHook, onClose: () => setRatingModalOpen(false), setHoveredRating: setHoveredRating, setMessageRatings: setMessageRatings, setSelectedMessage: setSelectedMessage, setTextRating: setTextRating, submitRating: submitRating })] }));
|
|
43078
|
+
}, toolTitles: toolTitles, agentParticipant: agentParticipant, buttonColor: buttonColor, teamAgentProfiles: teamAgentProfiles }), jsx(ChatCitationModal, { isOpen: citationModalOpen, citation: selectedCitation, participants: participants, soundSystem: soundSystem, onClose: () => setCitationModalOpen(false) }), jsx(ChatRatingModal, { isOpen: ratingModalOpen, selectedMessage: selectedMessage, postprocessedMessages: postprocessedMessages, messages: messages, hoveredRating: hoveredRating, messageRatings: messageRatings, textRating: textRating, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, mode: mode, isMobile: isMobileFromHook, onClose: () => setRatingModalOpen(false), setHoveredRating: setHoveredRating, setMessageRatings: setMessageRatings, setSelectedMessage: setSelectedMessage, setTextRating: setTextRating, submitRating: submitRating })] }));
|
|
43039
43079
|
}
|
|
43040
43080
|
|
|
43041
43081
|
/**
|