diff --git a/extensions/inference-cortex-extension/download.bat b/extensions/inference-cortex-extension/download.bat index fc359557c..fd20e8c8d 100644 --- a/extensions/inference-cortex-extension/download.bat +++ b/extensions/inference-cortex-extension/download.bat @@ -2,7 +2,7 @@ set BIN_PATH=./bin set SHARED_PATH=./../../electron/shared set /p CORTEX_VERSION=<./bin/version.txt -set ENGINE_VERSION=0.1.46 +set ENGINE_VERSION=0.1.49 @REM Download cortex.llamacpp binaries set DOWNLOAD_URL=https://github.com/janhq/cortex.llamacpp/releases/download/v%ENGINE_VERSION%/cortex.llamacpp-%ENGINE_VERSION%-windows-amd64 diff --git a/extensions/inference-cortex-extension/download.sh b/extensions/inference-cortex-extension/download.sh index 0c21e1987..c32160184 100755 --- a/extensions/inference-cortex-extension/download.sh +++ b/extensions/inference-cortex-extension/download.sh @@ -2,7 +2,7 @@ # Read CORTEX_VERSION CORTEX_VERSION=$(cat ./bin/version.txt) -ENGINE_VERSION=0.1.46 +ENGINE_VERSION=0.1.49 CORTEX_RELEASE_URL="https://github.com/janhq/cortex.cpp/releases/download" ENGINE_DOWNLOAD_URL="https://github.com/janhq/cortex.llamacpp/releases/download/v${ENGINE_VERSION}/cortex.llamacpp-${ENGINE_VERSION}" CUDA_DOWNLOAD_URL="https://github.com/janhq/cortex.llamacpp/releases/download/v${ENGINE_VERSION}" diff --git a/web/containers/Providers/ModelHandler.tsx b/web/containers/Providers/ModelHandler.tsx index cc7a0da80..2c027539e 100644 --- a/web/containers/Providers/ModelHandler.tsx +++ b/web/containers/Providers/ModelHandler.tsx @@ -135,7 +135,7 @@ export default function ModelHandler() { return } - const messageContent = message.content[0]?.text?.value + let messageContent = message.content[0]?.text?.value if (!messageContent) { console.warn( `Failed to update title for thread ${message.thread_id}: Responded content is null!` @@ -147,27 +147,17 @@ export default function ModelHandler() { // And no new line character is present // And non-alphanumeric characters should be removed if (messageContent.includes('\n')) { - console.warn( - `Failed to update title for thread ${message.thread_id}: Title can't contain new line character!` - ) - return + messageContent = messageContent.replace(/\n/g, ' ') + } + const match = messageContent.match(/<\/think>(.*)$/) + if (match) { + messageContent = match[1] } - // Remove non-alphanumeric characters const cleanedMessageContent = messageContent .replace(/[^\p{L}\s]+/gu, '') .trim() - // Split the message into words - const words = cleanedMessageContent.split(' ') - - if (words.length >= maxWordForThreadTitle) { - console.warn( - `Failed to update title for thread ${message.thread_id}: Title can't be greater than ${maxWordForThreadTitle} words!` - ) - return - } - // Do not persist empty message if (!cleanedMessageContent.trim().length) return @@ -368,7 +358,7 @@ export default function ModelHandler() { if (!threadMessages || threadMessages.length === 0) return - const summarizeFirstPrompt = `Summarize in a ${maxWordForThreadTitle}-word Title. Give the title only. "${threadMessages[0]?.content[0]?.text?.value}"` + const summarizeFirstPrompt = `Summarize in a ${maxWordForThreadTitle}-word Title. Give the title only. Here is the message: "${threadMessages[0]?.content[0]?.text?.value}"` // Prompt: Given this query from user {query}, return to me the summary in 10 words as the title const msgId = ulid()