From 5300e38622fa78799260582950279cdaa48bcd4a Mon Sep 17 00:00:00 2001 From: Sy Tran Dung Date: Tue, 22 Oct 2024 10:59:05 +0700 Subject: [PATCH] fix: chat UI send bad format message history after long response Signed-off-by: Sy Tran Dung --- package-lock.json | 4 ++-- schema.json | 4 ++-- static/scripts/chat.js | 9 ++++----- static/styles/chat.css | 8 ++++++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 68b05fa..99e90bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@platformatic/ai-warp", - "version": "0.5.0", + "version": "0.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@platformatic/ai-warp", - "version": "0.5.0", + "version": "0.5.1", "license": "Apache-2.0", "dependencies": { "@azure/openai": "^1.0.0-beta.12", diff --git a/schema.json b/schema.json index dafc797..68d9d23 100644 --- a/schema.json +++ b/schema.json @@ -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": { diff --git a/static/scripts/chat.js b/static/scripts/chat.js index 5995352..b8197d4 100644 --- a/static/scripts/chat.js +++ b/static/scripts/chat.js @@ -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') } /** diff --git a/static/styles/chat.css b/static/styles/chat.css index 5294b42..a7e84e6 100644 --- a/static/styles/chat.css +++ b/static/styles/chat.css @@ -105,3 +105,11 @@ #prompt-button:hover { cursor: pointer; } + +#prompt-button:disabled { + cursor: not-allowed; +} + +#prompt-button:disabled img { + opacity: 0.2; +}