mirror of
https://github.com/cocktailpeanut/dalai
synced 2025-03-24 12:24:22 +01:00
Fix character errors
List of changes: - Allow quotes (") and line breaks (\n). They no longer break the shell command. - Remove a bug where a line break followed by "[29;200H" is randomly added to the generated text
This commit is contained in:
parent
a5eaa0efa0
commit
d12a5b5acd
@ -179,7 +179,7 @@ form.addEventListener('submit', (e) => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
if (input.textContent) {
|
if (input.textContent) {
|
||||||
config.prompt = input.textContent
|
config.prompt = input.textContent.replaceAll("\n", "\\n").replaceAll('"', '\\\\\\""');
|
||||||
config.id = "TS-" + Date.now() + "-" + Math.floor(Math.random() * 100000)
|
config.id = "TS-" + Date.now() + "-" + Math.floor(Math.random() * 100000)
|
||||||
socket.emit('request', config)
|
socket.emit('request', config)
|
||||||
config.id = null
|
config.id = null
|
||||||
@ -232,6 +232,9 @@ socket.on('result', async ({ request, response }) => {
|
|||||||
let existing = document.querySelector(`[data-id='${id}']`)
|
let existing = document.querySelector(`[data-id='${id}']`)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.textContent = existing.textContent + response
|
existing.textContent = existing.textContent + response
|
||||||
|
existing.textContent = existing.textContent.replaceAll(/\r?\n\x1B\[\d+;\d+H./g, "");
|
||||||
|
existing.textContent = existing.textContent.replaceAll("\\n", "\n");
|
||||||
|
existing.textContent = existing.textContent.replaceAll('\\"', '"');
|
||||||
} else {
|
} else {
|
||||||
say(response, id)
|
say(response, id)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user