refactor(chatModal): improve code readability and formatting
This commit is contained in:
parent
2e16618e47
commit
7fbce31a50
1 changed files with 17 additions and 19 deletions
|
|
@ -115,16 +115,16 @@ export default function ChatModal({
|
||||||
newChatHistory.push(
|
newChatHistory.push(
|
||||||
chatItem.files
|
chatItem.files
|
||||||
? {
|
? {
|
||||||
isSend: !chatItem.is_bot,
|
isSend: !chatItem.is_bot,
|
||||||
message: chatItem.message,
|
message: chatItem.message,
|
||||||
thought: chatItem.intermediate_steps,
|
thought: chatItem.intermediate_steps,
|
||||||
files: chatItem.files,
|
files: chatItem.files,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
isSend: !chatItem.is_bot,
|
isSend: !chatItem.is_bot,
|
||||||
message: chatItem.message,
|
message: chatItem.message,
|
||||||
thought: chatItem.intermediate_steps,
|
thought: chatItem.intermediate_steps,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,9 +164,8 @@ export default function ChatModal({
|
||||||
const urlWs =
|
const urlWs =
|
||||||
process.env.NODE_ENV === "development"
|
process.env.NODE_ENV === "development"
|
||||||
? `ws://localhost:7860/chat/${flow.id}`
|
? `ws://localhost:7860/chat/${flow.id}`
|
||||||
: `${window.location.protocol === "https:" ? "wss" : "ws"}://${
|
: `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host
|
||||||
window.location.host
|
}/chat/${flow.id}`;
|
||||||
}/chat/${flow.id}`;
|
|
||||||
|
|
||||||
const newWs = new WebSocket(urlWs);
|
const newWs = new WebSocket(urlWs);
|
||||||
newWs.onopen = () => {
|
newWs.onopen = () => {
|
||||||
|
|
@ -224,7 +223,7 @@ export default function ChatModal({
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setErrorData({
|
setErrorData({
|
||||||
title: "There was an erro sending the message",
|
title: "There was an error sending the message",
|
||||||
list: [error.message],
|
list: [error.message],
|
||||||
});
|
});
|
||||||
setChatValue(data.message);
|
setChatValue(data.message);
|
||||||
|
|
@ -264,12 +263,11 @@ export default function ChatModal({
|
||||||
e.targetHandle.split("|")[2] === n.id
|
e.targetHandle.split("|")[2] === n.id
|
||||||
)
|
)
|
||||||
? [
|
? [
|
||||||
`${type} is missing ${
|
`${type} is missing ${template.display_name
|
||||||
template.display_name
|
? template.display_name
|
||||||
? template.display_name
|
: toNormalCase(template[t].name)
|
||||||
: toNormalCase(template[t].name)
|
}.`,
|
||||||
}.`,
|
]
|
||||||
]
|
|
||||||
: []
|
: []
|
||||||
),
|
),
|
||||||
[] as string[]
|
[] as string[]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue