fix: Object.hasOwn browser compatibility

This commit is contained in:
Jing Hua 2023-03-07 15:47:17 +08:00
parent c7504b1038
commit 21da7342eb
2 changed files with 11 additions and 2 deletions

View file

@ -53,6 +53,10 @@ const useSubmit = () => {
}
if (stream) {
if (stream.locked)
throw new Error(
'Oops, the stream is locked right now. Please try again'
);
const reader = stream.getReader();
let reading = true;
while (reading && useStore.getState().generating) {
@ -80,6 +84,11 @@ const useSubmit = () => {
setChats(updatedChats);
}
}
if (useStore.getState().generating) {
reader.cancel('Cancelled by user');
} else {
reader.cancel('Generation completed');
}
}
} catch (e: unknown) {
const err = (e as Error).message;

View file

@ -50369,7 +50369,7 @@ const bpe_ranks = dictZip(bpe_merges, range(0, bpe_merges.length));
const cache = {};
const bpe = (token) => {
if (Object.hasOwn(cache, token)) {
if (cache.hasOwnProperty(token)) {
return cache[token];
}
@ -50397,7 +50397,7 @@ const bpe = (token) => {
)
];
if (!Object.hasOwn(bpe_ranks, bigram)) {
if (!bpe_ranks.hasOwnProperty(bigram)) {
break;
}