Add error handling to openai message counting

This commit is contained in:
maver
2023-07-03 19:32:03 +02:00
parent 011278c533
commit ce8a71cf53

View File

@ -689,7 +689,7 @@ function prepareOpenAIMessages({
} }
const chat = chatCompletion.getChat(); const chat = chatCompletion.getChat();
openai_messages_count = chat.filter(x => x.role === "user" || x.role === "assistant").length; openai_messages_count = chat.filter(x => x?.role === "user" || x?.role === "assistant")?.length || 0;
return [chat, false]; return [chat, false];
} }