Spaces:
Build error
Build error
File size: 2,391 Bytes
fc15a4c 0bfcf81 5d07536 5da61b4 fe2328e 0bfcf81 4a6603b 2606dde 2804c18 5da61b4 fc15a4c 0bfcf81 4a6603b 0bfcf81 002f606 0bfcf81 fe2328e 0bfcf81 4a6603b 34857c4 fe2328e 4a6603b 0bfcf81 9405a81 2804c18 9405a81 fc15a4c b56bba1 9405a81 5b779a6 6434339 4a6603b 9405a81 4a6603b b7b2c8c 2606dde 002f606 5d07536 9405a81 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
<script lang="ts">
import { goto } from "$app/navigation";
import { base } from "$app/paths";
import { page } from "$app/stores";
import { PUBLIC_APP_DISCLAIMER } from "$env/static/public";
import ChatWindow from "$lib/components/chat/ChatWindow.svelte";
import { ERROR_MESSAGES, error } from "$lib/stores/errors";
import { pendingMessage } from "$lib/stores/pendingMessage";
import { pendingMessageIdToRetry } from "$lib/stores/pendingMessageIdToRetry";
import { findCurrentModel } from "$lib/utils/models";
import { share } from "$lib/utils/share";
import type { PageData } from "./$types";
export let data: PageData;
let loading = false;
async function createConversation() {
try {
loading = true;
const res = await fetch(`${base}/conversation`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fromShare: $page.params.id,
model: data.model,
}),
});
if (!res.ok) {
error.set("Error while creating conversation, try again.");
console.error("Error while creating conversation: " + (await res.text()));
return;
}
const { conversationId } = await res.json();
return conversationId;
} catch (err) {
error.set(ERROR_MESSAGES.default);
console.error(String(err));
throw err;
}
}
async function shareConversation() {
const url = `${window.location.origin}${window.location.pathname}`;
share(url, data.title);
}
</script>
<svelte:head>
<title>{data.title}</title>
</svelte:head>
<ChatWindow
{loading}
shared={true}
messages={data.messages}
searches={data.searches}
on:message={(ev) =>
createConversation()
.then((convId) => {
$pendingMessage = ev.detail;
return goto(`${base}/conversation/${convId}`, { invalidateAll: true });
})
.finally(() => (loading = false))}
on:share={shareConversation}
on:retry={(ev) =>
createConversation()
.then((convId) => {
$pendingMessageIdToRetry = ev.detail.id;
$pendingMessage = ev.detail.content;
return goto(`${base}/conversation/${convId}`, { invalidateAll: true });
})
.finally(() => (loading = false))}
models={data.models}
currentModel={findCurrentModel(data.models, data.model)}
settings={data.settings}
loginRequired={!$page.error &&
(data.requiresLogin
? !data.user
: !data.settings.ethicsModalAcceptedAt && !!PUBLIC_APP_DISCLAIMER)}
/>
|