Spaces:
Running
Running
JoFrost
commited on
Commit
•
0e3f3da
1
Parent(s):
7a073fd
gtag
Browse files- src/routes/+layout.svelte +6 -0
- src/routes/+page.svelte +10 -0
- src/routes/conversation/[id]/+page.svelte +50 -14
src/routes/+layout.svelte
CHANGED
@@ -112,6 +112,12 @@
|
|
112 |
}
|
113 |
|
114 |
onMount(async () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
await refreshChats();
|
116 |
});
|
117 |
|
|
|
112 |
}
|
113 |
|
114 |
onMount(async () => {
|
115 |
+
try {
|
116 |
+
dataLayer.push({ event: "Avertissement"});
|
117 |
+
} catch (e) {
|
118 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
119 |
+
console.log(e);
|
120 |
+
}
|
121 |
await refreshChats();
|
122 |
});
|
123 |
|
src/routes/+page.svelte
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<script lang="ts">
|
|
|
2 |
import { goto, invalidate } from "$app/navigation";
|
3 |
import { base } from "$app/paths";
|
4 |
import { PUBLIC_APP_NAME } from "$env/static/public";
|
@@ -10,6 +11,15 @@
|
|
10 |
import { params_writable } from "../routes/conversation/[id]/ParamsWritable";
|
11 |
import { curr_model_writable, curr_model_writable_string } from "./LayoutWritable";
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
let curr_model_id = 0;
|
14 |
|
15 |
curr_model_writable.subscribe((val) => {
|
|
|
1 |
<script lang="ts">
|
2 |
+
import { onMount } from 'svelte';
|
3 |
import { goto, invalidate } from "$app/navigation";
|
4 |
import { base } from "$app/paths";
|
5 |
import { PUBLIC_APP_NAME } from "$env/static/public";
|
|
|
11 |
import { params_writable } from "../routes/conversation/[id]/ParamsWritable";
|
12 |
import { curr_model_writable, curr_model_writable_string } from "./LayoutWritable";
|
13 |
|
14 |
+
onMount(() => {
|
15 |
+
try {
|
16 |
+
dataLayer.push({ event: "virtualPageview", nom_modele: ["No"] });
|
17 |
+
} catch (e) {
|
18 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
19 |
+
console.log(e);
|
20 |
+
}
|
21 |
+
});
|
22 |
+
|
23 |
let curr_model_id = 0;
|
24 |
|
25 |
curr_model_writable.subscribe((val) => {
|
src/routes/conversation/[id]/+page.svelte
CHANGED
@@ -16,7 +16,12 @@
|
|
16 |
import type { Message } from "$lib/types/Message";
|
17 |
import { PUBLIC_APP_DISCLAIMER } from "$env/static/public";
|
18 |
import { pipeline, Pipeline, env as env_transformers } from "@xenova/transformers";
|
19 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
20 |
import { map_writable, phi_writable } from "$lib/components/LoadingModalWritable.js";
|
21 |
import { params_writable } from "./ParamsWritable.js";
|
22 |
import { addMessageToChat, getChats, getMessages, getTitle, getModel } from "../../LocalDB.js";
|
@@ -59,17 +64,22 @@
|
|
59 |
let lastMessage: any = undefined;
|
60 |
switch (e.data.status) {
|
61 |
case "initiate":
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
break;
|
65 |
|
66 |
case "progress":
|
67 |
isloading_writable.set(true);
|
68 |
if (e.data.no_progress_bar == undefined || e.data.no_progress_bar == false) {
|
69 |
map_writable.set([e.data.file, e.data.progress]);
|
70 |
-
}
|
71 |
-
|
72 |
-
map_writable.set(["phi", "-1"])
|
73 |
}
|
74 |
break;
|
75 |
|
@@ -80,8 +90,12 @@
|
|
80 |
break;
|
81 |
|
82 |
case "ready":
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
isloading_writable.set(false);
|
86 |
is_init_writable.set(false);
|
87 |
phi_writable.set(false);
|
@@ -94,16 +108,20 @@
|
|
94 |
lastMessage.webSearchId = e.data.searchID;
|
95 |
lastMessage.updatedAt = new Date();
|
96 |
messages = [...messages];
|
97 |
-
}
|
98 |
-
|
99 |
-
pipelineWorker.postMessage({ command: "abort" })
|
100 |
}
|
101 |
break;
|
102 |
|
103 |
case "aborted":
|
104 |
case "complete":
|
105 |
if (e.data.id_now == id_now) {
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
107 |
lastMessage = messages[messages.length - 1];
|
108 |
lastMessage.webSearchId = e.data.searchID;
|
109 |
lastMessage.updatedAt = new Date();
|
@@ -157,7 +175,12 @@
|
|
157 |
isCode: false,
|
158 |
};
|
159 |
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
addMessageToChat(conversationId, msg, curr_model);
|
163 |
|
@@ -319,6 +342,12 @@
|
|
319 |
lastLoadedMessages = res;
|
320 |
}
|
321 |
id_now = randomUUID();
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
}
|
323 |
});
|
324 |
|
@@ -351,6 +380,13 @@
|
|
351 |
|
352 |
pipelineWorker.addEventListener("message", onMessageReceived);
|
353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
if ($pendingMessage) {
|
355 |
const val = $pendingMessage;
|
356 |
const messageId = $pendingMessageIdToRetry || undefined;
|
@@ -384,7 +420,7 @@
|
|
384 |
on:retry={(event) => writeMessage(event.detail.content, event.detail.id)}
|
385 |
on:vote={(event) => voteMessage(event.detail.score, event.detail.id)}
|
386 |
on:share={() => shareConversation($page.params.id, data.title)}
|
387 |
-
on:stop={() => (isAborted = true, pipelineWorker.postMessage({ command: "abort" }))}
|
388 |
models={data.models}
|
389 |
currentModel={findCurrentModel([...data.models, ...data.oldModels], curr_model)}
|
390 |
settings={data.settings}
|
|
|
16 |
import type { Message } from "$lib/types/Message";
|
17 |
import { PUBLIC_APP_DISCLAIMER } from "$env/static/public";
|
18 |
import { pipeline, Pipeline, env as env_transformers } from "@xenova/transformers";
|
19 |
+
import {
|
20 |
+
isloading_writable,
|
21 |
+
curr_model_writable,
|
22 |
+
is_init_writable,
|
23 |
+
cancel_writable,
|
24 |
+
} from "../../LayoutWritable.js";
|
25 |
import { map_writable, phi_writable } from "$lib/components/LoadingModalWritable.js";
|
26 |
import { params_writable } from "./ParamsWritable.js";
|
27 |
import { addMessageToChat, getChats, getMessages, getTitle, getModel } from "../../LocalDB.js";
|
|
|
64 |
let lastMessage: any = undefined;
|
65 |
switch (e.data.status) {
|
66 |
case "initiate":
|
67 |
+
try {
|
68 |
+
if (e.data.file == "tokenizer.json")
|
69 |
+
// Avoid to send the tag multiple times
|
70 |
+
dataLayer.push({ event: "debut_chargement_chat", nom_modele: [e.data.name] });
|
71 |
+
} catch (e) {
|
72 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
73 |
+
console.log(e);
|
74 |
+
}
|
75 |
break;
|
76 |
|
77 |
case "progress":
|
78 |
isloading_writable.set(true);
|
79 |
if (e.data.no_progress_bar == undefined || e.data.no_progress_bar == false) {
|
80 |
map_writable.set([e.data.file, e.data.progress]);
|
81 |
+
} else {
|
82 |
+
map_writable.set(["phi", "-1"]);
|
|
|
83 |
}
|
84 |
break;
|
85 |
|
|
|
90 |
break;
|
91 |
|
92 |
case "ready":
|
93 |
+
try {
|
94 |
+
dataLayer.push({ event: "fin_chargement_chat", nom_modele: [e.data.model] });
|
95 |
+
} catch (e) {
|
96 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
97 |
+
console.log(e);
|
98 |
+
}
|
99 |
isloading_writable.set(false);
|
100 |
is_init_writable.set(false);
|
101 |
phi_writable.set(false);
|
|
|
108 |
lastMessage.webSearchId = e.data.searchID;
|
109 |
lastMessage.updatedAt = new Date();
|
110 |
messages = [...messages];
|
111 |
+
} else {
|
112 |
+
pipelineWorker.postMessage({ command: "abort" });
|
|
|
113 |
}
|
114 |
break;
|
115 |
|
116 |
case "aborted":
|
117 |
case "complete":
|
118 |
if (e.data.id_now == id_now) {
|
119 |
+
try {
|
120 |
+
dataLayer.push({ event: "reponse_message", nom_modele: [e.data.model] });
|
121 |
+
} catch (e) {
|
122 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
123 |
+
console.log(e);
|
124 |
+
}
|
125 |
lastMessage = messages[messages.length - 1];
|
126 |
lastMessage.webSearchId = e.data.searchID;
|
127 |
lastMessage.updatedAt = new Date();
|
|
|
175 |
isCode: false,
|
176 |
};
|
177 |
|
178 |
+
try {
|
179 |
+
dataLayer.push({ event: "envoi_message", nom_modele: [curr_model_obj.name] });
|
180 |
+
} catch (e) {
|
181 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
182 |
+
console.log(e);
|
183 |
+
}
|
184 |
|
185 |
addMessageToChat(conversationId, msg, curr_model);
|
186 |
|
|
|
342 |
lastLoadedMessages = res;
|
343 |
}
|
344 |
id_now = randomUUID();
|
345 |
+
try {
|
346 |
+
dataLayer.push({ event: "virtualPageview", nom_modele: [curr_model] });
|
347 |
+
} catch (e) {
|
348 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
349 |
+
console.log(e);
|
350 |
+
}
|
351 |
}
|
352 |
});
|
353 |
|
|
|
380 |
|
381 |
pipelineWorker.addEventListener("message", onMessageReceived);
|
382 |
|
383 |
+
try {
|
384 |
+
dataLayer.push({ event: "virtualPageview", nom_modele: [curr_model] });
|
385 |
+
} catch (e) {
|
386 |
+
console.log("Google Tag Manager might not be loaded. Ignoring the error");
|
387 |
+
console.log(e);
|
388 |
+
}
|
389 |
+
|
390 |
if ($pendingMessage) {
|
391 |
const val = $pendingMessage;
|
392 |
const messageId = $pendingMessageIdToRetry || undefined;
|
|
|
420 |
on:retry={(event) => writeMessage(event.detail.content, event.detail.id)}
|
421 |
on:vote={(event) => voteMessage(event.detail.score, event.detail.id)}
|
422 |
on:share={() => shareConversation($page.params.id, data.title)}
|
423 |
+
on:stop={() => ((isAborted = true), pipelineWorker.postMessage({ command: "abort" }))}
|
424 |
models={data.models}
|
425 |
currentModel={findCurrentModel([...data.models, ...data.oldModels], curr_model)}
|
426 |
settings={data.settings}
|