Forward error messages from Cohere streams
This commit is contained in:
parent
813476d72a
commit
ee3718ad7a
|
@ -36,7 +36,13 @@ async function parseCohereStream(jsonStream, request, response) {
|
|||
} catch (e) {
|
||||
break;
|
||||
}
|
||||
if (json.event_type === 'text-generation') {
|
||||
if (json.message) {
|
||||
const message = json.message || 'Unknown error';
|
||||
const chunk = { error: { message: message } };
|
||||
response.write(`data: ${JSON.stringify(chunk)}\n\n`);
|
||||
partialData = '';
|
||||
break;
|
||||
} else if (json.event_type === 'text-generation') {
|
||||
const text = json.text || '';
|
||||
const chunk = { choices: [{ text }] };
|
||||
response.write(`data: ${JSON.stringify(chunk)}\n\n`);
|
||||
|
|
Loading…
Reference in New Issue