1
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 "" is randomly added to the generated text
This commit is contained in:
Pi 2023-03-17 22:43:14 -07:00 committed by GitHub
parent a5eaa0efa0
commit d12a5b5acd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}