mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 22:23:59 +01:00
fix: Object.hasOwn browser compatibility
This commit is contained in:
parent
c7504b1038
commit
21da7342eb
|
@ -53,6 +53,10 @@ const useSubmit = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
|
if (stream.locked)
|
||||||
|
throw new Error(
|
||||||
|
'Oops, the stream is locked right now. Please try again'
|
||||||
|
);
|
||||||
const reader = stream.getReader();
|
const reader = stream.getReader();
|
||||||
let reading = true;
|
let reading = true;
|
||||||
while (reading && useStore.getState().generating) {
|
while (reading && useStore.getState().generating) {
|
||||||
|
@ -80,6 +84,11 @@ const useSubmit = () => {
|
||||||
setChats(updatedChats);
|
setChats(updatedChats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (useStore.getState().generating) {
|
||||||
|
reader.cancel('Cancelled by user');
|
||||||
|
} else {
|
||||||
|
reader.cancel('Generation completed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const err = (e as Error).message;
|
const err = (e as Error).message;
|
||||||
|
|
|
@ -50369,7 +50369,7 @@ const bpe_ranks = dictZip(bpe_merges, range(0, bpe_merges.length));
|
||||||
const cache = {};
|
const cache = {};
|
||||||
|
|
||||||
const bpe = (token) => {
|
const bpe = (token) => {
|
||||||
if (Object.hasOwn(cache, token)) {
|
if (cache.hasOwnProperty(token)) {
|
||||||
return cache[token];
|
return cache[token];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50397,7 +50397,7 @@ const bpe = (token) => {
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!Object.hasOwn(bpe_ranks, bigram)) {
|
if (!bpe_ranks.hasOwnProperty(bigram)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue