From 7162f9d562855ca669ae472d58795b8d89003d55 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:27:54 +0300 Subject: [PATCH] Cohere: Swap message and tool plan in extractMessageFromData --- public/script.js | 2 +- public/scripts/openai.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index cbc21dbfd..8e90368fe 100644 --- a/public/script.js +++ b/public/script.js @@ -5436,7 +5436,7 @@ function extractMessageFromData(data) { case 'novel': return data.output; case 'openai': - return data?.choices?.[0]?.message?.content ?? data?.choices?.[0]?.text ?? data?.text ?? data?.message?.tool_plan ?? data?.message?.content?.[0]?.text ?? ''; + return data?.choices?.[0]?.message?.content ?? data?.choices?.[0]?.text ?? data?.text ?? data?.message?.content?.[0]?.text ?? data?.message?.tool_plan ?? ''; default: return ''; } diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 94a537c07..7fb23e711 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1973,11 +1973,11 @@ async function sendOpenAIRequest(type, messages, signal) { } function getStreamingReply(data) { - if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) { + if (oai_settings.chat_completion_source === chat_completion_sources.CLAUDE) { return data?.delta?.text || ''; - } else if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) { + } else if (oai_settings.chat_completion_source === chat_completion_sources.MAKERSUITE) { return data?.candidates?.[0]?.content?.parts?.[0]?.text || ''; - } else if (oai_settings.chat_completion_source == chat_completion_sources.COHERE) { + } else if (oai_settings.chat_completion_source === chat_completion_sources.COHERE) { return data?.delta?.message?.content?.text || data?.delta?.message?.tool_plan || ''; } else { return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';