@promptbook/components 0.112.0-28 → 0.112.0-29
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 +57 -21
- 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 +57 -21
- 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-29';
|
|
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
|
|
@@ -21675,7 +21675,7 @@ const DEFAULT_FEEDBACK_ERROR_MESSAGE = 'Failed to save feedback. Please try agai
|
|
|
21675
21675
|
* @private component of `<Chat/>`
|
|
21676
21676
|
*/
|
|
21677
21677
|
function useChatRatings(options) {
|
|
21678
|
-
const { messages, onFeedback, feedbackMode, isMobile } = options;
|
|
21678
|
+
const { messages, onFeedback, feedbackMode, feedbackTranslations, isMobile } = options;
|
|
21679
21679
|
const [ratingModalOpen, setRatingModalOpen] = useState(false);
|
|
21680
21680
|
const [selectedMessage, setSelectedMessage] = useState(null);
|
|
21681
21681
|
const [messageRatings, setMessageRatings] = useState(new Map());
|
|
@@ -21718,7 +21718,7 @@ function useChatRatings(options) {
|
|
|
21718
21718
|
};
|
|
21719
21719
|
}, []);
|
|
21720
21720
|
const submitRating = useCallback(async () => {
|
|
21721
|
-
var _a;
|
|
21721
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21722
21722
|
if (!selectedMessage) {
|
|
21723
21723
|
return;
|
|
21724
21724
|
}
|
|
@@ -21742,14 +21742,16 @@ function useChatRatings(options) {
|
|
|
21742
21742
|
const feedbackResponse = await onFeedback(feedbackData);
|
|
21743
21743
|
showFeedbackStatus({
|
|
21744
21744
|
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),
|
|
21745
|
+
? ((_b = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSuccessMessage) !== null && _b !== void 0 ? _b : DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE)
|
|
21746
|
+
: ((_c = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackSuccessMessage) !== null && _c !== void 0 ? _c : DEFAULT_FEEDBACK_SUCCESS_MESSAGE)),
|
|
21747
21747
|
variant: 'success',
|
|
21748
21748
|
});
|
|
21749
21749
|
}
|
|
21750
21750
|
catch (error) {
|
|
21751
21751
|
console.error('Error submitting feedback:', error);
|
|
21752
|
-
const message = error instanceof Error
|
|
21752
|
+
const message = error instanceof Error
|
|
21753
|
+
? error.message
|
|
21754
|
+
: ((_d = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackErrorMessage) !== null && _d !== void 0 ? _d : DEFAULT_FEEDBACK_ERROR_MESSAGE);
|
|
21753
21755
|
showFeedbackStatus({ message, variant: 'error' });
|
|
21754
21756
|
return;
|
|
21755
21757
|
}
|
|
@@ -21764,15 +21766,26 @@ function useChatRatings(options) {
|
|
|
21764
21766
|
});
|
|
21765
21767
|
showFeedbackStatus({
|
|
21766
21768
|
message: feedbackMode === 'report_issue'
|
|
21767
|
-
? DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE
|
|
21768
|
-
: DEFAULT_FEEDBACK_SUCCESS_MESSAGE,
|
|
21769
|
+
? ((_e = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSuccessMessage) !== null && _e !== void 0 ? _e : DEFAULT_REPORT_ISSUE_SUCCESS_MESSAGE)
|
|
21770
|
+
: ((_f = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackSuccessMessage) !== null && _f !== void 0 ? _f : DEFAULT_FEEDBACK_SUCCESS_MESSAGE),
|
|
21769
21771
|
variant: 'success',
|
|
21770
21772
|
});
|
|
21771
21773
|
}
|
|
21772
21774
|
setRatingModalOpen(false);
|
|
21773
21775
|
setTextRating('');
|
|
21774
21776
|
setSelectedMessage(null);
|
|
21775
|
-
}, [
|
|
21777
|
+
}, [
|
|
21778
|
+
feedbackMode,
|
|
21779
|
+
feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackErrorMessage,
|
|
21780
|
+
feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.feedbackSuccessMessage,
|
|
21781
|
+
feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSuccessMessage,
|
|
21782
|
+
messages,
|
|
21783
|
+
messageRatings,
|
|
21784
|
+
onFeedback,
|
|
21785
|
+
selectedMessage,
|
|
21786
|
+
showFeedbackStatus,
|
|
21787
|
+
textRating,
|
|
21788
|
+
]);
|
|
21776
21789
|
useEffect(() => {
|
|
21777
21790
|
if (ratingModalOpen && isMobile) {
|
|
21778
21791
|
document.body.style.overflow = 'hidden';
|
|
@@ -40288,7 +40301,7 @@ const ChatMessageItem = memo(
|
|
|
40288
40301
|
// Or make normal function from this?
|
|
40289
40302
|
(props) => {
|
|
40290
40303
|
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;
|
|
40304
|
+
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
40305
|
const { isComplete = true,
|
|
40293
40306
|
// <- TODO: Destruct all `messages` properties like `isComplete`
|
|
40294
40307
|
} = message;
|
|
@@ -40707,7 +40720,8 @@ const ChatMessageItem = memo(
|
|
|
40707
40720
|
: () => {
|
|
40708
40721
|
setExpandedMessageId(null);
|
|
40709
40722
|
setLocalHoveredRating(0);
|
|
40710
|
-
}, children: isReportIssueFeedbackMode ? (jsx("button", { type: "button", onClick: () => handleRating(message, 1), className: styles$5.feedbackIssueButton, "aria-label":
|
|
40723
|
+
}, 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) ||
|
|
40724
|
+
'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
40725
|
'--star-inactive-color': mode === 'LIGHT' ? '#ccc' : '#555',
|
|
40712
40726
|
}, children: "\u2B50" }, star)))) : (jsx("span", { onClick: () => handleRating(message, currentRating || 1), className: classNames(styles$5.ratingStar, currentRating && styles$5.active), style: {
|
|
40713
40727
|
'--star-inactive-color': mode === 'LIGHT' ? '#888' : '#666',
|
|
@@ -40789,6 +40803,9 @@ const ChatMessageItem = memo(
|
|
|
40789
40803
|
if (prev.feedbackMode !== next.feedbackMode) {
|
|
40790
40804
|
return false;
|
|
40791
40805
|
}
|
|
40806
|
+
if (prev.feedbackTranslations !== next.feedbackTranslations) {
|
|
40807
|
+
return false;
|
|
40808
|
+
}
|
|
40792
40809
|
if (prev.handleRating !== next.handleRating) {
|
|
40793
40810
|
return false;
|
|
40794
40811
|
}
|
|
@@ -40814,7 +40831,7 @@ ChatMessageItem.displayName = 'ChatMessageItem';
|
|
|
40814
40831
|
* @private component of `<Chat/>`
|
|
40815
40832
|
*/
|
|
40816
40833
|
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;
|
|
40834
|
+
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
40835
|
const firstMessage = messages[0];
|
|
40819
40836
|
const firstMsgContent = (firstMessage === null || firstMessage === void 0 ? void 0 : firstMessage.content) || '';
|
|
40820
40837
|
const firstMsgLines = firstMsgContent.split(/\r?\n/).length;
|
|
@@ -40826,7 +40843,7 @@ function ChatMessageList(props) {
|
|
|
40826
40843
|
const isLastMessage = index === messages.length - 1;
|
|
40827
40844
|
const isExpanded = expandedMessageId === message.id;
|
|
40828
40845
|
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)));
|
|
40846
|
+
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
40847
|
}), jsx("div", { style: { height: 100 } })] }));
|
|
40831
40848
|
}
|
|
40832
40849
|
/**
|
|
@@ -40851,7 +40868,8 @@ function resolveRenderedMessageKey(message) {
|
|
|
40851
40868
|
* @private component of `<Chat/>`
|
|
40852
40869
|
*/
|
|
40853
40870
|
function ChatRatingModal(props) {
|
|
40854
|
-
|
|
40871
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
40872
|
+
const { isOpen, selectedMessage, postprocessedMessages, messages, hoveredRating, messageRatings, textRating, feedbackMode, feedbackTranslations, mode, isMobile, onClose, setHoveredRating, setMessageRatings, setSelectedMessage, setTextRating, submitRating, } = props;
|
|
40855
40873
|
if (!isOpen || !selectedMessage) {
|
|
40856
40874
|
return null;
|
|
40857
40875
|
}
|
|
@@ -40876,7 +40894,9 @@ function ChatRatingModal(props) {
|
|
|
40876
40894
|
if (event.target === event.currentTarget && isMobile) {
|
|
40877
40895
|
onClose();
|
|
40878
40896
|
}
|
|
40879
|
-
}, children: jsxs("div", { className: styles$5.ratingModalContent, children: [jsx("h3", { children: isReportIssueMode
|
|
40897
|
+
}, children: jsxs("div", { className: styles$5.ratingModalContent, children: [jsx("h3", { children: isReportIssueMode
|
|
40898
|
+
? ((_a = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueModalTitle) !== null && _a !== void 0 ? _a : 'Report issue')
|
|
40899
|
+
: ((_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
40900
|
const nextRatings = new Map(previousRatings);
|
|
40881
40901
|
nextRatings.set(selectedMessage.id || selectedMessage.content /* <-[??] */, star);
|
|
40882
40902
|
return nextRatings;
|
|
@@ -40889,11 +40909,21 @@ function ChatRatingModal(props) {
|
|
|
40889
40909
|
: mode === 'LIGHT'
|
|
40890
40910
|
? '#ccc'
|
|
40891
40911
|
: '#555',
|
|
40892
|
-
}, children: "\u2B50" }, star))) })),
|
|
40912
|
+
}, 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
|
|
40913
|
+
? ((_d = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueExpectedAnswerLabel) !== null && _d !== void 0 ? _d : 'What should the answer include?')
|
|
40914
|
+
: ((_e = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.expectedAnswerLabel) !== null && _e !== void 0 ? _e : 'Expected answer:'), jsx("textarea", { placeholder: selectedMessage.content ||
|
|
40915
|
+
(feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.expectedAnswerPlaceholder) ||
|
|
40916
|
+
'Expected answer (optional)', defaultValue: selectedMessage.expectedAnswer || selectedMessage.content, onChange: (event) => {
|
|
40893
40917
|
if (selectedMessage) {
|
|
40894
40918
|
setSelectedMessage({ ...selectedMessage, expectedAnswer: event.target.value });
|
|
40895
40919
|
}
|
|
40896
|
-
}, className: styles$5.ratingInput }), isReportIssueMode
|
|
40920
|
+
}, className: styles$5.ratingInput }), isReportIssueMode
|
|
40921
|
+
? ((_f = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueDetailsLabel) !== null && _f !== void 0 ? _f : 'Issue details:')
|
|
40922
|
+
: ((_g = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.noteLabel) !== null && _g !== void 0 ? _g : 'Note:'), jsx("textarea", { placeholder: isReportIssueMode
|
|
40923
|
+
? ((_h = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueDetailsPlaceholder) !== null && _h !== void 0 ? _h : 'Describe what went wrong (optional)')
|
|
40924
|
+
: ((_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
|
|
40925
|
+
? ((_k = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.reportIssueSubmitLabel) !== null && _k !== void 0 ? _k : 'Report issue')
|
|
40926
|
+
: ((_l = feedbackTranslations === null || feedbackTranslations === void 0 ? void 0 : feedbackTranslations.submitLabel) !== null && _l !== void 0 ? _l : 'Submit') })] })] }) }));
|
|
40897
40927
|
}
|
|
40898
40928
|
|
|
40899
40929
|
/**
|
|
@@ -42853,7 +42883,7 @@ function isLatestMessageVisible(chatMessagesElement, messageSelector) {
|
|
|
42853
42883
|
* @public exported from `@promptbook/components`
|
|
42854
42884
|
*/
|
|
42855
42885
|
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;
|
|
42886
|
+
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
42887
|
const buttonColor = useMemo(() => Color.from(buttonColorRaw || '#0066cc'), [buttonColorRaw]);
|
|
42858
42888
|
const agentParticipant = useMemo(() => participants.find((participant) => participant.name === 'AGENT'), [participants]);
|
|
42859
42889
|
const postprocessedMessages = useMemo(() => {
|
|
@@ -42924,7 +42954,13 @@ function Chat(props) {
|
|
|
42924
42954
|
const shouldShowScrollToBottom = !isAutoScrolling && !isLatestMessageInView;
|
|
42925
42955
|
const lastMessage = postprocessedMessages[postprocessedMessages.length - 1];
|
|
42926
42956
|
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({
|
|
42957
|
+
const { state: { ratingModalOpen, selectedMessage, messageRatings, textRating, hoveredRating, expandedMessageId, feedbackStatus, }, actions: { setRatingModalOpen, setSelectedMessage, setMessageRatings, setTextRating, setHoveredRating, setExpandedMessageId, handleRating, submitRating, }, } = useChatRatings({
|
|
42958
|
+
messages,
|
|
42959
|
+
onFeedback,
|
|
42960
|
+
feedbackMode,
|
|
42961
|
+
feedbackTranslations,
|
|
42962
|
+
isMobile: isMobileFromHook,
|
|
42963
|
+
});
|
|
42928
42964
|
const [toolCallModalOpen, setToolCallModalOpen] = useState(false);
|
|
42929
42965
|
const [selectedToolCallState, setSelectedToolCallState] = useState(null);
|
|
42930
42966
|
const [citationModalOpen, setCitationModalOpen] = useState(false);
|
|
@@ -43023,7 +43059,7 @@ function Chat(props) {
|
|
|
43023
43059
|
}, [postprocessedMessages, soundSystem]);
|
|
43024
43060
|
return (jsxs(Fragment, { children: [feedbackStatus && (jsx("div", { className: classNames(styles$5.feedbackStatus, feedbackStatus.variant === 'success'
|
|
43025
43061
|
? 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) => {
|
|
43062
|
+
: 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
43063
|
setSelectedToolCallState({
|
|
43028
43064
|
identity: getToolCallIdentity(toolCall),
|
|
43029
43065
|
fallbackToolCall: toolCall,
|
|
@@ -43035,7 +43071,7 @@ function Chat(props) {
|
|
|
43035
43071
|
}, 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
43072
|
setToolCallModalOpen(false);
|
|
43037
43073
|
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 })] }));
|
|
43074
|
+
}, 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
43075
|
}
|
|
43040
43076
|
|
|
43041
43077
|
/**
|