Continue generation feature (#707)
Browse files* Initial work on continue feature
* Move continue button
* Fix websearch with continue
* Make it work with every model
* Update src/routes/conversation/[id]/+server.ts
Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu>
* fixes
* async all the things
* add reduce comment
* remove log
* Only show loading indicator if not continuing
---------
Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu>
Files changed (11)
- .env.template+4-2
- src/lib/buildPrompt.ts+18-16
- src/lib/components/ContinueBtn.svelteAdded+13
- src/lib/components/chat/ChatMessage.svelte+1
- src/lib/components/chat/ChatMessages.svelte+2-1
- src/lib/components/chat/ChatWindow.svelte+17-2
- src/lib/server/endpoints/endpoints.ts+1
- src/lib/server/endpoints/tgi/endpointTgi.ts+13-2
- src/lib/types/Message.ts+1
- src/routes/conversation/[id]/+page.svelte+76-25
- src/routes/conversation/[id]/+server.ts+65-35
56 unmodified lines5758596061626352 unmodified lines11611711811912012112256 unmodified lines"repetition_penalty": 1.2,"top_k": 50,"truncate": 3072,"max_new_tokens": 1024}},{52 unmodified lines"repetition_penalty": 1.2,"top_k": 50,"truncate": 4096,"max_new_tokens": 4096}},{56 unmodified lines575859606162636452 unmodified lines11711811912012112212312456 unmodified lines"repetition_penalty": 1.2,"top_k": 50,"truncate": 3072,"max_new_tokens": 1024,"stop" : ["</s>", " </s><s>[INST] "]}},{52 unmodified lines"repetition_penalty": 1.2,"top_k": 50,"truncate": 4096,"max_new_tokens": 4096,"stop": [" </s><s>[INST] "]}},{
12 unmodified lines1314151617183 unmodified lines2223242526272829303132333435363738394041424344454647484950515253545556575824 unmodified lines8384858687888912 unmodified lineswebSearch?: WebSearch;preprompt?: string;files?: File[];}export async function buildPrompt({3 unmodified linespreprompt,id,}: buildPromptOptions): Promise<string> {if (webSearch && webSearch.context) {const lastMsg = messages.slice(-1)[0];const messagesWithoutLastUsrMsg = messages.slice(0, -1);const previousUserMessages = messages.filter((el) => el.from === "user").slice(0, -1);const previousQuestions =previousUserMessages.length > 0? `Previous questions: \n${previousUserMessages.map(({ content }) => `- ${content}`).join("\n")}`: "";const currentDate = format(new Date(), "MMMM d, yyyy");messages = [...messagesWithoutLastUsrMsg,{from: "user",content: `I searched the web using the query: ${webSearch.searchQuery}. Today is ${currentDate} and here are the results:=====================${webSearch.context}=====================${previousQuestions}Answer the question: ${lastMsg.content}`,},];}// section to handle potential files inputif (model.multimodal) {messages = await Promise.all(messages.map(async (el) => {let content = el.content;if (el.from === "user") {24 unmodified linesreturn (model.chatPromptRender({ messages, preprompt })// Not super precise, but it's truncated in the model's backend anyway.split(" ").slice(-(model.parameters?.truncate ?? 0))12 unmodified lines131415161718193 unmodified lines232425262728293031323334353637383940414243444546474849505152535455565758596024 unmodified lines8586878889909112 unmodified lineswebSearch?: WebSearch;preprompt?: string;files?: File[];continue?: boolean;}export async function buildPrompt({3 unmodified linespreprompt,id,}: buildPromptOptions): Promise<string> {let modifiedMessages = [...messages];if (webSearch && webSearch.context) {// find index of the last user messageconst lastUsrMsgIndex = modifiedMessages.map((el) => el.from).lastIndexOf("user");// combine all the other previous questions into one stringconst previousUserMessages = modifiedMessages.filter((el) => el.from === "user").slice(0, -1);const previousQuestions =previousUserMessages.length > 0? `Previous questions: \n${previousUserMessages.map(({ content }) => `- ${content}`).join("\n")}`: "";const currentDate = format(new Date(), "MMMM d, yyyy");// update the last user message directly (that way if the last message is an assistant partial answer, we keep the beginning of that answer)modifiedMessages[lastUsrMsgIndex] = {from: "user",content: `I searched the web using the query: ${webSearch.searchQuery}. Today is ${currentDate} and here are the results:=====================${webSearch.context}=====================${previousQuestions}Answer the question: ${messages[lastUsrMsgIndex].content} `,};}// section to handle potential files inputif (model.multimodal) {modifiedMessages = await Promise.all(modifiedMessages.map(async (el) => {let content = el.content;if (el.from === "user") {24 unmodified linesreturn (model.chatPromptRender({ messages: modifiedMessages, preprompt })// Not super precise, but it's truncated in the model's backend anyway.split(" ").slice(-(model.parameters?.truncate ?? 0))
12345678910111213<script lang="ts"> import CarbonContinue from "~icons/carbon/continue";
export let classNames = "";</script>
<button type="button" on:click class="btn flex h-8 rounded-lg border bg-white px-3 py-1 text-gray-500 shadow-sm transition-all hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600 {classNames}"> <CarbonContinue class="mr-2 text-xs " /> Continue</button>12 unmodified lines13141516171812 unmodified linesimport CarbonDownload from "~icons/carbon/download";import CarbonThumbsUp from "~icons/carbon/thumbs-up";import CarbonThumbsDown from "~icons/carbon/thumbs-down";import { PUBLIC_SEP_TOKEN } from "$lib/constants/publicSepToken";import type { Model } from "$lib/types/Model";12 unmodified lines1314151617181912 unmodified linesimport CarbonDownload from "~icons/carbon/download";import CarbonThumbsUp from "~icons/carbon/thumbs-up";import CarbonThumbsDown from "~icons/carbon/thumbs-down";import { PUBLIC_SEP_TOKEN } from "$lib/constants/publicSepToken";import type { Model } from "$lib/types/Model";
53 unmodified lines545556575859606162636453 unmodified lineswebSearchMessages={i === messages.length - 1 ? webSearchMessages : []}on:retryon:vote/>{:else}<ChatIntroduction {models} {currentModel} on:message />{/each}{#if pending}<ChatMessagemessage={{ from: "assistant", content: "", id: randomUUID() }}model={currentModel}53 unmodified lines54555657585960616263646553 unmodified lineswebSearchMessages={i === messages.length - 1 ? webSearchMessages : []}on:retryon:voteon:continue/>{:else}<ChatIntroduction {models} {currentModel} on:message />{/each}{#if pending && messages[messages.length - 1]?.from === "user"}<ChatMessagemessage={{ from: "assistant", content: "", id: randomUUID() }}model={currentModel}
23 unmodified lines24252627282918 unmodified lines48495051525370 unmodified lines12412512612712812943 unmodified lines17317417517617717817918023 unmodified linesimport UploadBtn from "../UploadBtn.svelte";import file2base64 from "$lib/utils/file2base64";import { useSettingsStore } from "$lib/stores/settings";export let messages: Message[] = [];export let loading = false;18 unmodified linesshare: void;stop: void;retry: { id: Message["id"]; content: string };}>();const handleSubmit = () => {70 unmodified lines}}}on:voteon:retry={(ev) => {if (!loading) dispatch("retry", ev.detail);}}43 unmodified linescontent: messages[messages.length - 1].content,})}/>{:else if currentModel.multimodal}<UploadBtn bind:files classNames="ml-auto" />{/if}</div><form23 unmodified lines2425262728293018 unmodified lines4950515253545570 unmodified lines12612712812913013113243 unmodified lines17617717817918018118218318418518618718818919019119219319419523 unmodified linesimport UploadBtn from "../UploadBtn.svelte";import file2base64 from "$lib/utils/file2base64";import { useSettingsStore } from "$lib/stores/settings";import ContinueBtn from "../ContinueBtn.svelte";export let messages: Message[] = [];export let loading = false;18 unmodified linesshare: void;stop: void;retry: { id: Message["id"]; content: string };continue: { id: Message["id"] };}>();const handleSubmit = () => {70 unmodified lines}}}on:voteon:continueon:retry={(ev) => {if (!loading) dispatch("retry", ev.detail);}}43 unmodified linescontent: messages[messages.length - 1].content,})}/>{:else}<div class="ml-auto gap-2">{#if currentModel.multimodal}<UploadBtn bind:files classNames="ml-auto" />{/if}{#if messages && messages[messages.length - 1]?.interrupted && !isReadOnly}<ContinueBtnon:click={() =>dispatch("continue", {id: messages[messages.length - 1].id,})}/>{/if}</div>{/if}</div><form
13 unmodified lines14151617181913 unmodified linespreprompt?: Conversation["preprompt"];_id?: Conversation["_id"];};}interface CommonEndpoint {13 unmodified lines1415161718192013 unmodified linespreprompt?: Conversation["preprompt"];_id?: Conversation["_id"];};continue?: boolean;}interface CommonEndpoint {
14 unmodified lines15161718192021221 unmodified line24252627282914 unmodified linesexport function endpointTgi(input: z.input<typeof endpointTgiParametersSchema>): Endpoint {const { url, accessToken, model, authorization } = endpointTgiParametersSchema.parse(input);return async ({ conversation }) => {const prompt = await buildPrompt({messages: conversation.messages,webSearch: conversation.messages[conversation.messages.length - 1].webSearch,preprompt: conversation.preprompt,1 unmodified lineid: conversation._id,});return textGenerationStream({parameters: { ...model.parameters, return_full_text: false },14 unmodified lines1516171819202122231 unmodified line2526272829303132333435363738394014 unmodified linesexport function endpointTgi(input: z.input<typeof endpointTgiParametersSchema>): Endpoint {const { url, accessToken, model, authorization } = endpointTgiParametersSchema.parse(input);return async ({ conversation, continue: messageContinue }) => {let prompt = await buildPrompt({messages: conversation.messages,webSearch: conversation.messages[conversation.messages.length - 1].webSearch,preprompt: conversation.preprompt,1 unmodified lineid: conversation._id,});if (messageContinue) {// start with the full prompt, and for each stop token, try to remove it from the end of the promptprompt = model.parameters.stop.reduce((acc: string, curr: string) => {if (acc.endsWith(curr)) {return acc.slice(0, acc.length - curr.length);}return acc;}, prompt.trimEnd());}return textGenerationStream({parameters: { ...model.parameters, return_full_text: false },
10 unmodified lines1112131410 unmodified lineswebSearch?: WebSearch;score?: -1 | 0 | 1;files?: string[]; // can contain either the hash of the file or the b64 encoded image data on the client side when uploading};10 unmodified lines111213141510 unmodified lineswebSearch?: WebSearch;score?: -1 | 0 | 1;files?: string[]; // can contain either the hash of the file or the b64 encoded image data on the client side when uploadinginterrupted?: boolean;};
63 unmodified lines6465666768697071721 unmodified line7475767778798081828384858612 unmodified lines991001011021031041051061071081091101111121131 unmodified line115116117118119120121122123158 unmodified lines28228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731818 unmodified lines33733833934034134263 unmodified lines}}// this function is used to send new message to the backendsasync function writeMessage(message: string, messageId = randomUUID()) {if (!message.trim()) return;try {$isAborted = false;loading = true;1 unmodified line// first we check if the messageId already exists, indicating a retrylet retryMessageIndex = messages.findIndex((msg) => msg.id === messageId);const isRetry = retryMessageIndex !== -1;// if it's not a retry we just use the whole arrayif (!isRetry) {retryMessageIndex = messages.length;}const module = await import("browser-image-resizer");// currently, only IDEFICS is supported by TGI12 unmodified lines);// slice up to the point of the retrymessages = [...messages.slice(0, retryMessageIndex),{from: "user",content: message,id: messageId,files: isRetry ? messages[retryMessageIndex].files : resizedImages,},];files = [];1 unmodified linemethod: "POST",headers: { "Content-Type": "application/json" },body: JSON.stringify({inputs: message,id: messageId,is_retry: isRetry,web_search: $webSearchParameters.useSearch,files: isRetry ? undefined : resizedImages,}),158 unmodified lines// only used in case of creating new conversations (from the parent POST endpoint)if ($pendingMessage) {files = $pendingMessage.files;await writeMessage($pendingMessage.content);$pendingMessage = undefined;}});async function onMessage(event: CustomEvent<string>) {if (!data.shared) {writeMessage(event.detail);} else {convFromShared().then(async (convId) => {await goto(`${base}/conversation/${convId}`, { invalidateAll: true });}).then(() => writeMessage(event.detail)).finally(() => (loading = false));}}async function onRetry(event: CustomEvent<{ id: Message["id"]; content: string }>) {if (!data.shared) {writeMessage(event.detail.content, event.detail.id);} else {convFromShared().then(async (convId) => {await goto(`${base}/conversation/${convId}`, { invalidateAll: true });}).then(() => writeMessage(event.detail.content, event.detail.id)).finally(() => (loading = false));}}$: $page.params.id, (($isAborted = true), (loading = false));$: title = data.conversations.find((conv) => conv.id === $page.params.id)?.title ?? data.title;</script>18 unmodified linesbind:fileson:message={onMessage}on:retry={onRetry}on:vote={(event) => voteMessage(event.detail.score, event.detail.id)}on:share={() => shareConversation($page.params.id, data.title)}on:stop={() => (($isAborted = true), (loading = false))}63 unmodified lines64656667686970717273747576777879801 unmodified line82838485868788899091929394959697989910010110212 unmodified lines1151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451 unmodified line147148149150151152153154155156158 unmodified lines31531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736818 unmodified lines38738838939039139239363 unmodified lines}}// this function is used to send new message to the backendsasync function writeMessage({prompt,messageId = randomUUID(),isRetry = false,isContinue = false,}: {prompt?: string;messageId?: ReturnType<typeof randomUUID>;isRetry?: boolean;isContinue?: boolean;}): Promise<void> {try {$isAborted = false;loading = true;1 unmodified line// first we check if the messageId already exists, indicating a retrylet msgIndex = messages.findIndex((msg) => msg.id === messageId);if (msgIndex === -1) {msgIndex = messages.length - 1;}if (isRetry && messages[msgIndex].from === "assistant") {throw new Error("Trying to retry a message that is not from user");}if (isContinue && messages[msgIndex].from === "user") {throw new Error("Trying to continue a message that is not from assistant");}// const isNewMessage = !isRetry && !isContinue;const module = await import("browser-image-resizer");// currently, only IDEFICS is supported by TGI12 unmodified lines);// slice up to the point of the retryif (isRetry) {messages = [...messages.slice(0, msgIndex),{from: "user",content: messages[msgIndex].content,id: messageId,files: messages[msgIndex].files,},];} else if (!isContinue) {// or add a new message if its not a continue requestif (!prompt) {throw new Error("Prompt is undefined");}messages = [...messages,{from: "user",content: prompt ?? "",id: messageId,files: resizedImages,},];}files = [];1 unmodified linemethod: "POST",headers: { "Content-Type": "application/json" },body: JSON.stringify({inputs: prompt,id: messageId,is_retry: isRetry,is_continue: isContinue,web_search: $webSearchParameters.useSearch,files: isRetry ? undefined : resizedImages,}),158 unmodified lines// only used in case of creating new conversations (from the parent POST endpoint)if ($pendingMessage) {files = $pendingMessage.files;await writeMessage({ prompt: $pendingMessage.content });$pendingMessage = undefined;}});async function onMessage(event: CustomEvent<string>) {if (!data.shared) {await writeMessage({ prompt: event.detail });} else {await convFromShared().then(async (convId) => {await goto(`${base}/conversation/${convId}`, { invalidateAll: true });}).then(async () => await writeMessage({ prompt: event.detail })).finally(() => (loading = false));}}async function onRetry(event: CustomEvent<{ id: Message["id"]; content: string }>) {if (!data.shared) {await writeMessage({prompt: event.detail.content,messageId: event.detail.id,isRetry: true,});} else {await convFromShared().then(async (convId) => {await goto(`${base}/conversation/${convId}`, { invalidateAll: true });}).then(async () =>await writeMessage({prompt: event.detail.content,messageId: event.detail.id,isRetry: true,})).finally(() => (loading = false));}}async function onContinue(event: CustomEvent<{ id: Message["id"] }>) {if (!data.shared) {writeMessage({ messageId: event.detail.id, isContinue: true });}}$: $page.params.id, (($isAborted = true), (loading = false));$: title = data.conversations.find((conv) => conv.id === $page.params.id)?.title ?? data.title;</script>18 unmodified linesbind:fileson:message={onMessage}on:retry={onRetry}on:continue={onContinue}on:vote={(event) => voteMessage(event.detail.score, event.detail.id)}on:share={() => shareConversation($page.params.id, data.title)}on:stop={() => (($isAborted = true), (loading = false))}
90 unmodified lines91929394959697989910010110210310431 unmodified lines1361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721739 unmodified lines18318418518618718818919019119216 unmodified lines20921021121221321421516 unmodified lines23223323423523623723823924024124224324424524624724843 unmodified lines2922932942952962972983 unmodified lines3023033043053063077 unmodified lines3153163173183193203 unmodified lines32432532632732832933033133233333433533633733833934034190 unmodified linesconst {inputs: newPrompt,id: messageId,is_retry,web_search: webSearch,files: b64files,} = z.object({inputs: z.string().trim().min(1),id: z.optional(z.string().uuid()),is_retry: z.optional(z.boolean()),web_search: z.optional(z.boolean()),files: z.optional(z.array(z.string())),})31 unmodified lineshashes = await Promise.all(files.map(async (file) => await uploadFile(file, conv)));}// get the list of messages// while checking for retrieslet messages = (() => {if (is_retry && messageId) {// if the message is a retry, replace the message and remove the messages after itlet retryMessageIdx = conv.messages.findIndex((message) => message.id === messageId);if (retryMessageIdx === -1) {retryMessageIdx = conv.messages.length;}return [...conv.messages.slice(0, retryMessageIdx),{content: newPrompt,from: "user",id: messageId as Message["id"],updatedAt: new Date(),files: conv.messages[retryMessageIdx]?.files,},];} // else append the message at the bottomreturn [...conv.messages,{content: newPrompt,from: "user",id: (messageId as Message["id"]) || crypto.randomUUID(),createdAt: new Date(),updatedAt: new Date(),files: hashes,},];})() satisfies Message[];await collections.conversations.updateOne(9 unmodified lines});// we now build the streamconst stream = new ReadableStream({async start(controller) {const updates: MessageUpdate[] = [];function update(newUpdate: MessageUpdate) {if (newUpdate.type !== "stream") {16 unmodified linesconst summarizeIfNeeded = (async () => {if (conv.title === "New Chat" && messages.length === 1) {try {conv.title = (await summarize(newPrompt)) ?? conv.title;update({ type: "status", status: "title", message: conv.title });} catch (e) {console.error(e);16 unmodified lineslet webSearchResults: WebSearch | undefined;if (webSearch) {webSearchResults = await runWebSearch(conv, newPrompt, update);}messages[messages.length - 1].webSearch = webSearchResults;conv.messages = messages;try {const endpoint = await model.getEndpoint();for await (const output of await endpoint({ conversation: conv })) {// if not generated_text is here it means the generation is not doneif (!output.generated_text) {// else we get the next token43 unmodified lines...messages.slice(0, -1),{...messages[messages.length - 1],content: output.generated_text,updates,updatedAt: new Date(),},3 unmodified lines} catch (e) {update({ type: "status", status: "error", message: (e as Error).message });}await collections.conversations.updateOne({_id: convId,7 unmodified lines});update({type: "finalAnswer",text: messages[messages.length - 1].content,3 unmodified linesreturn;},async cancel() {await collections.conversations.updateOne({_id: convId,},{$set: {messages,title: conv.title,updatedAt: new Date(),},});},});90 unmodified lines91929394959697989910010110210310410510631 unmodified lines1381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861879 unmodified lines19719819920020120220320420520620720820921016 unmodified lines22722822923023123223316 unmodified lines25025125225325425525625725825926026126226326426526626726826927027143 unmodified lines3153163173183193203213223 unmodified lines3263273283293303313327 unmodified lines3403413423433443453463473483 unmodified lines35235335435535635735835936036136236336436536636736836937037190 unmodified linesconst {inputs: newPrompt,id: messageId,is_retry: isRetry,is_continue: isContinue,web_search: webSearch,files: b64files,} = z.object({inputs: z.optional(z.string().trim().min(1)),id: z.optional(z.string().uuid()),is_retry: z.optional(z.boolean()),is_continue: z.optional(z.boolean()),web_search: z.optional(z.boolean()),files: z.optional(z.array(z.string())),})31 unmodified lineshashes = await Promise.all(files.map(async (file) => await uploadFile(file, conv)));}// can only call isContinue on the last message idif (isContinue && conv.messages[conv.messages.length - 1].id !== messageId) {throw error(400, "Can only continue the last message");}// get the list of messages// while checking for retrieslet messages = (() => {// for retries we slice and rewrite the last user messageif (isRetry && messageId) {// if the message is a retry, replace the message and remove the messages after itlet retryMessageIdx = conv.messages.findIndex((message) => message.id === messageId);if (retryMessageIdx === -1) {retryMessageIdx = conv.messages.length;}return [...conv.messages.slice(0, retryMessageIdx),{content: conv.messages[retryMessageIdx]?.content,from: "user",id: messageId as Message["id"],updatedAt: new Date(),files: conv.messages[retryMessageIdx]?.files,},];} else if (isContinue && messageId) {// for continue we do nothing and expand the last assistant messagereturn conv.messages;} else {// in normal conversation we add an extra user messagereturn [...conv.messages,{content: newPrompt ?? "",from: "user",id: (messageId as Message["id"]) || crypto.randomUUID(),createdAt: new Date(),updatedAt: new Date(),files: hashes,},];} // else append the message at the bottom})() satisfies Message[];await collections.conversations.updateOne(9 unmodified lines});let doneStreaming = false;// we now build the streamconst stream = new ReadableStream({async start(controller) {const updates: MessageUpdate[] = isContinue? conv.messages[conv.messages.length - 1].updates ?? []: [];function update(newUpdate: MessageUpdate) {if (newUpdate.type !== "stream") {16 unmodified linesconst summarizeIfNeeded = (async () => {if (conv.title === "New Chat" && messages.length === 1) {try {conv.title = (await summarize(messages[0].content)) ?? conv.title;update({ type: "status", status: "title", message: conv.title });} catch (e) {console.error(e);16 unmodified lineslet webSearchResults: WebSearch | undefined;if (webSearch && !isContinue) {webSearchResults = await runWebSearch(conv, messages[messages.length - 1].content, update);messages[messages.length - 1].webSearch = webSearchResults;} else if (isContinue) {webSearchResults = messages[messages.length - 1].webSearch;}conv.messages = messages;const previousContent = isContinue? conv.messages.find((message) => message.id === messageId)?.content ?? "": "";try {const endpoint = await model.getEndpoint();for await (const output of await endpoint({ conversation: conv, continue: isContinue })) {// if not generated_text is here it means the generation is not doneif (!output.generated_text) {// else we get the next token43 unmodified lines...messages.slice(0, -1),{...messages[messages.length - 1],content: previousContent + output.generated_text,interrupted: !output.token.special, // if its a special token it finished on its own, else it was interruptedupdates,updatedAt: new Date(),},3 unmodified lines} catch (e) {update({ type: "status", status: "error", message: (e as Error).message });}await collections.conversations.updateOne({_id: convId,7 unmodified lines});// used to detect if cancel() is called bc of interrupt or just because the connection closesdoneStreaming = true;update({type: "finalAnswer",text: messages[messages.length - 1].content,3 unmodified linesreturn;},async cancel() {if (!doneStreaming) {await collections.conversations.updateOne({_id: convId,},{$set: {messages,title: conv.title,updatedAt: new Date(),},});}},});
.env.template+4-2
src/lib/buildPrompt.ts+18-16
src/lib/components/ContinueBtn.svelteAdded+13
src/lib/components/chat/ChatMessage.svelte+1
src/lib/components/chat/ChatMessages.svelte+2-1
src/lib/components/chat/ChatWindow.svelte+17-2
src/lib/server/endpoints/endpoints.ts+1
src/lib/server/endpoints/tgi/endpointTgi.ts+13-2
src/lib/types/Message.ts+1
src/routes/conversation/[id]/+page.svelte+76-25
src/routes/conversation/[id]/+server.ts+65-35