Cohere: Swap message and tool plan in extractMessageFromData

7162f9d562855ca669ae472d58795b8d89003d55

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +4 -4Ignore whitespace
public/script.js+1 -1
@@ -5436,7 +5436,7 @@ function extractMessageFromData(data) {
5436 case 'novel':5436 case 'novel':
5437 return data.output;5437 return data.output;
5438 case 'openai':5438 case 'openai':
5439 return data?.choices?.[0]?.message?.content ?? data?.choices?.[0]?.text ?? data?.text ?? data?.message?.tool_plan ?? data?.message?.content?.[0]?.text ?? '';5439 return data?.choices?.[0]?.message?.content ?? data?.choices?.[0]?.text ?? data?.text ?? data?.message?.content?.[0]?.text ?? data?.message?.tool_plan ?? '';
5440 default:5440 default:
5441 return '';5441 return '';
5442 }5442 }
public/scripts/openai.js+3 -3
@@ -1973,11 +1973,11 @@ async function sendOpenAIRequest(type, messages, signal) {
1973}1973}
19741974
1975function getStreamingReply(data) {1975function getStreamingReply(data) {
1976 if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) {1976 if (oai_settings.chat_completion_source === chat_completion_sources.CLAUDE) {
1977 return data?.delta?.text || '';1977 return data?.delta?.text || '';
1978 } else if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) {1978 } else if (oai_settings.chat_completion_source === chat_completion_sources.MAKERSUITE) {
1979 return data?.candidates?.[0]?.content?.parts?.[0]?.text || '';1979 return data?.candidates?.[0]?.content?.parts?.[0]?.text || '';
1980 } else if (oai_settings.chat_completion_source == chat_completion_sources.COHERE) {1980 } else if (oai_settings.chat_completion_source === chat_completion_sources.COHERE) {
1981 return data?.delta?.message?.content?.text || data?.delta?.message?.tool_plan || '';1981 return data?.delta?.message?.content?.text || data?.delta?.message?.tool_plan || '';
1982 } else {1982 } else {
1983 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';1983 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';