mirror of
https://github.com/cocktailpeanut/dalai
synced 2024-11-20 23:07:32 +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.stopPropagation()
|
||||
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)
|
||||
socket.emit('request', config)
|
||||
config.id = null
|
||||
@ -232,6 +232,9 @@ socket.on('result', async ({ request, response }) => {
|
||||
let existing = document.querySelector(`[data-id='${id}']`)
|
||||
if (existing) {
|
||||
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 {
|
||||
say(response, id)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user