Fix JSON parse exception when Claude finishes streaming (khanon/oai-reverse-proxy!25)

This commit is contained in:
breathingmanually 2023-07-20 01:57:50 +00:00 committed by khanon
parent c31540e54e
commit 576423d1f8
1 changed files with 1 additions and 1 deletions

View File

@ -282,7 +282,7 @@ function convertEventsToFinalResponse(events: string[], req: Request) {
* the final SSE event before the "DONE" event, so we can reuse that
*/
const lastEvent = events[events.length - 2].toString();
const data = JSON.parse(lastEvent.slice("data: ".length));
const data = JSON.parse(lastEvent.slice(lastEvent.indexOf("data: ") + "data: ".length));
const response: AnthropicCompletionResponse = {
...data,
log_id: req.id,