Skip to content

Commit

Permalink
fix: chat UI send bad format message history after long response (#121)
Browse files Browse the repository at this point in the history
Signed-off-by: Sy Tran Dung <sytrancsvn@gmail.com>
sytranvn authored Dec 9, 2024
1 parent 34f540c commit 6cd28ee
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$id": "https://schemas.platformatic.com/@platformatic/ai-warp/0.5.0.json",
"version": "0.5.0",
"$id": "https://schemas.platformatic.com/@platformatic/ai-warp/0.5.1.json",
"version": "0.5.1",
"title": "Ai Warp Config",
"type": "object",
"properties": {
9 changes: 4 additions & 5 deletions static/scripts/chat.js
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ async function handlePrompt (prompt) {
*/
async function promptAiWarp (message) {
promptLock = true
promptButton.setAttribute('disabled', '')

let chatHistoryStartIndex
if (messages.length >= 11) {
@@ -98,6 +99,7 @@ async function promptAiWarp (message) {
message.response[message.responseIndex] = res.body
} catch (err) {
promptLock = false
promptButton.removeAttribute('disabled')
message.errored = true
console.error(err)
}
@@ -292,13 +294,10 @@ async function drawStreamedMessageContents (parent, message) {
}
}

// Not great, but works for now
message.response[message.responseIndex] = []
for (const line of fullResponse.split('\n')) {
message.response[message.responseIndex].push(line)
}
message.response[message.responseIndex] = [fullResponse]

promptLock = false
promptButton.removeAttribute('disabled')
}

/**
8 changes: 8 additions & 0 deletions static/styles/chat.css
Original file line number Diff line number Diff line change
@@ -105,3 +105,11 @@
#prompt-button:hover {
cursor: pointer;
}

#prompt-button:disabled {
cursor: not-allowed;
}

#prompt-button:disabled img {
opacity: 0.2;
}

0 comments on commit 6cd28ee

Please sign in to comment.