@markprompt/core
Advanced tools
Comparing version 0.22.0 to 0.22.1
@@ -71,2 +71,20 @@ import defaults from 'defaults'; | ||
}); | ||
const data = parseEncodedJSONHeader(res, 'x-markprompt-data'); | ||
if (res.headers.get('Content-Type')?.includes('application/json')) { | ||
const json = await res.json(); | ||
if (isChatCompletion(json) && isMarkpromptMetadata(data)) { | ||
return { ...json.choices[0].message, ...data }; | ||
} | ||
else { | ||
if (isMarkpromptMetadata(data)) { | ||
yield data; | ||
} | ||
throw new Error('Malformed response from Markprompt API', { | ||
cause: json, | ||
}); | ||
} | ||
} | ||
if (isMarkpromptMetadata(data)) { | ||
yield data; | ||
} | ||
if (!res.ok || !res.body) { | ||
@@ -91,17 +109,2 @@ if (options.signal?.aborted) { | ||
} | ||
const data = parseEncodedJSONHeader(res, 'x-markprompt-data'); | ||
if (res.headers.get('Content-Type')?.includes('application/json')) { | ||
const json = await res.json(); | ||
if (isChatCompletion(json) && isMarkpromptMetadata(data)) { | ||
return { ...json.choices[0].message, ...data }; | ||
} | ||
else { | ||
throw new Error('Malformed response from Markprompt API', { | ||
cause: json, | ||
}); | ||
} | ||
} | ||
if (isMarkpromptMetadata(data)) { | ||
yield data; | ||
} | ||
// eslint-disable-next-line prefer-const | ||
@@ -108,0 +111,0 @@ let completion = {}; |
{ | ||
"name": "@markprompt/core", | ||
"version": "0.22.0", | ||
"version": "0.22.1", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58358
755