Fixed and added conditions to flows without chat
This commit is contained in:
parent
e020e23124
commit
7bfe0c88c1
2 changed files with 31 additions and 37 deletions
|
|
@ -8,6 +8,7 @@ export default function ChatInput({
|
||||||
sendMessage,
|
sendMessage,
|
||||||
setChatValue,
|
setChatValue,
|
||||||
inputRef,
|
inputRef,
|
||||||
|
noInput,
|
||||||
}) {
|
}) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!lockChat && inputRef.current) {
|
if (!lockChat && inputRef.current) {
|
||||||
|
|
@ -32,7 +33,7 @@ export default function ChatInput({
|
||||||
}}
|
}}
|
||||||
rows={1}
|
rows={1}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
disabled={lockChat}
|
disabled={lockChat || noInput}
|
||||||
style={{
|
style={{
|
||||||
resize: "none",
|
resize: "none",
|
||||||
bottom: `${inputRef?.current?.scrollHeight}px`,
|
bottom: `${inputRef?.current?.scrollHeight}px`,
|
||||||
|
|
@ -48,7 +49,7 @@ export default function ChatInput({
|
||||||
setChatValue(e.target.value);
|
setChatValue(e.target.value);
|
||||||
}}
|
}}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
lockChat
|
lockChat || noInput
|
||||||
? " form-modal-lock-true bg-input "
|
? " form-modal-lock-true bg-input "
|
||||||
: " form-modal-lock-false",
|
: " form-modal-lock-false",
|
||||||
"form-modal-lockchat"
|
"form-modal-lockchat"
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,6 @@ export default function FormModal({
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
function sendMessage() {
|
function sendMessage() {
|
||||||
if (chatValue !== "") {
|
|
||||||
let nodeValidationErrors = validateNodes(reactFlowInstance);
|
let nodeValidationErrors = validateNodes(reactFlowInstance);
|
||||||
if (nodeValidationErrors.length === 0) {
|
if (nodeValidationErrors.length === 0) {
|
||||||
setLockChat(true);
|
setLockChat(true);
|
||||||
|
|
@ -354,6 +353,7 @@ export default function FormModal({
|
||||||
description: flow.description,
|
description: flow.description,
|
||||||
});
|
});
|
||||||
setTabsState((old) => {
|
setTabsState((old) => {
|
||||||
|
if (!chatKey) return old;
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[id.current].formKeysData.input_keys[chatKey] = "";
|
newTabsState[id.current].formKeysData.input_keys[chatKey] = "";
|
||||||
return newTabsState;
|
return newTabsState;
|
||||||
|
|
@ -364,12 +364,6 @@ export default function FormModal({
|
||||||
list: nodeValidationErrors,
|
list: nodeValidationErrors,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setErrorData({
|
|
||||||
title: "Error sending message",
|
|
||||||
list: ["The message cannot be empty."],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function clearChat() {
|
function clearChat() {
|
||||||
setChatHistory([]);
|
setChatHistory([]);
|
||||||
|
|
@ -549,13 +543,12 @@ export default function FormModal({
|
||||||
<div className="langflow-chat-input">
|
<div className="langflow-chat-input">
|
||||||
<ChatInput
|
<ChatInput
|
||||||
chatValue={chatValue}
|
chatValue={chatValue}
|
||||||
|
noInput={!chatKey}
|
||||||
lockChat={lockChat}
|
lockChat={lockChat}
|
||||||
sendMessage={sendMessage}
|
sendMessage={sendMessage}
|
||||||
setChatValue={(value) => {
|
setChatValue={(value) => {
|
||||||
setChatValue(value);
|
setChatValue(value);
|
||||||
setTabsState((old) => {
|
setTabsState((old) => {
|
||||||
// chatKey is undefined when there are no chat input keys
|
|
||||||
if (!chatKey) return old;
|
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[id.current].formKeysData.input_keys[
|
newTabsState[id.current].formKeysData.input_keys[
|
||||||
chatKey
|
chatKey
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue