Fixed chat not getting message
This commit is contained in:
parent
db7f5c7582
commit
5a412b33fe
1 changed files with 12 additions and 16 deletions
|
|
@ -20,23 +20,22 @@ export default function IOView({ children, open, setOpen }): JSX.Element {
|
||||||
const inputs = useFlowStore((state) => state.inputs).filter(
|
const inputs = useFlowStore((state) => state.inputs).filter(
|
||||||
(input) => input.type !== "ChatInput"
|
(input) => input.type !== "ChatInput"
|
||||||
);
|
);
|
||||||
|
const chatInput = useFlowStore((state) => state.inputs).find(
|
||||||
|
(input) => input.type === "ChatInput"
|
||||||
|
);
|
||||||
const outputs = useFlowStore((state) => state.outputs).filter(
|
const outputs = useFlowStore((state) => state.outputs).filter(
|
||||||
(output) => output.type !== "ChatOutput"
|
(output) => output.type !== "ChatOutput"
|
||||||
);
|
);
|
||||||
|
const chatOutput = useFlowStore((state) => state.outputs).find(
|
||||||
|
(output) => output.type === "ChatOutput"
|
||||||
|
);
|
||||||
const nodes = useFlowStore((state) => state.nodes).filter(
|
const nodes = useFlowStore((state) => state.nodes).filter(
|
||||||
(node) =>
|
(node) =>
|
||||||
(inputs.some((input) => input.id === node.id) ||
|
(inputs.some((input) => input.id === node.id) ||
|
||||||
outputs.some((output) => output.id === node.id)) &&
|
outputs.some((output) => output.id === node.id))
|
||||||
node.type !== "ChatInput" &&
|
|
||||||
node.type !== "ChatOutput"
|
|
||||||
);
|
);
|
||||||
const haveChat =
|
const haveChat =
|
||||||
useFlowStore((state) => state.outputs).some(
|
chatInput || chatOutput
|
||||||
(output) => output.type === "ChatOutput"
|
|
||||||
) ||
|
|
||||||
useFlowStore((state) => state.inputs).some(
|
|
||||||
(input) => input.type === "ChatInput"
|
|
||||||
);
|
|
||||||
const [selectedTab, setSelectedTab] = useState(
|
const [selectedTab, setSelectedTab] = useState(
|
||||||
inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0
|
inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0
|
||||||
);
|
);
|
||||||
|
|
@ -59,14 +58,11 @@ export default function IOView({ children, open, setOpen }): JSX.Element {
|
||||||
setIsBuilding(true);
|
setIsBuilding(true);
|
||||||
setLockChat(true);
|
setLockChat(true);
|
||||||
setChatValue("");
|
setChatValue("");
|
||||||
const chatInputId = inputs
|
const chatInputNode = nodes.find((node) => node.id === chatInput?.id);
|
||||||
.map((obj) => obj.id)
|
if (chatInputNode) {
|
||||||
.find((inputId) => inputId.includes("ChatInput"));
|
let newNode = cloneDeep(chatInputNode);
|
||||||
const chatInput: NodeType = getNode(chatInputId!) as NodeType;
|
|
||||||
if (chatInput) {
|
|
||||||
let newNode = cloneDeep(chatInput);
|
|
||||||
newNode.data.node!.template["message"].value = chatValue;
|
newNode.data.node!.template["message"].value = chatValue;
|
||||||
setNode(chatInputId!, newNode);
|
setNode(chatInput!.id, newNode);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
await buildFlow().catch((err) => {
|
await buildFlow().catch((err) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue