Skip to content

Commit

Permalink
Polyfill safari 14 (huggingface#149)
Browse files Browse the repository at this point in the history
* add core-js and necessary polyfills

* set TS target to ES2015

* set ES2018 as default since it's prob enough

* remove --host added by mistake

* replace usage of array.prototype.at by more compatible alternative

* remove core-js and replaceAll polyfill

* fix wrong usage of crypto global
  • Loading branch information
Grsmto authored May 2, 2023
1 parent a415295 commit 9c038aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/chat/ChatMessages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
// If last message is from user, scroll to bottom
$: if (messages.at(-1)?.from === "user") {
$: if (messages[messages.length - 1]?.from === "user") {
scrollToBottom();
}
</script>
Expand Down
7 changes: 4 additions & 3 deletions src/routes/conversation/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
// final message
if (data.generated_text) {
const lastMessage = messages.at(-1);
const lastMessage = messages[messages.length - 1];
if (lastMessage) {
lastMessage.content = data.generated_text;
messages = [...messages];
Expand All @@ -89,7 +90,7 @@
}
if (!data.token.special) {
const lastMessage = messages.at(-1);
const lastMessage = messages[messages.length - 1];
if (lastMessage?.from !== "assistant") {
// First token has a space at the beginning, trim it
Expand All @@ -112,7 +113,7 @@
});
}
async function writeMessage(message: string, messageId = crypto.randomUUID()) {
async function writeMessage(message: string, messageId = randomUUID()) {
if (!message.trim()) return;
try {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
"strict": true,
"target": "ES2018"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
Expand Down

0 comments on commit 9c038aa

Please sign in to comment.