ResponseMessage.svelte 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. <script lang="ts">
  2. import { toast } from 'svelte-sonner';
  3. import dayjs from 'dayjs';
  4. import { createEventDispatcher } from 'svelte';
  5. import { onMount, tick, getContext } from 'svelte';
  6. import type { Writable } from 'svelte/store';
  7. import type { i18n as i18nType } from 'i18next';
  8. const i18n = getContext<Writable<i18nType>>('i18n');
  9. const dispatch = createEventDispatcher();
  10. import { createNewFeedback, getFeedbackById, updateFeedbackById } from '$lib/apis/evaluations';
  11. import { getChatById } from '$lib/apis/chats';
  12. import { generateTags } from '$lib/apis';
  13. import { config, models, settings, TTSWorker, user } from '$lib/stores';
  14. import { synthesizeOpenAISpeech } from '$lib/apis/audio';
  15. import { imageGenerations } from '$lib/apis/images';
  16. import {
  17. copyToClipboard as _copyToClipboard,
  18. approximateToHumanReadable,
  19. getMessageContentParts,
  20. sanitizeResponseContent,
  21. createMessagesList,
  22. formatDate
  23. } from '$lib/utils';
  24. import { WEBUI_BASE_URL } from '$lib/constants';
  25. import Name from './Name.svelte';
  26. import ProfileImage from './ProfileImage.svelte';
  27. import Skeleton from './Skeleton.svelte';
  28. import Image from '$lib/components/common/Image.svelte';
  29. import Tooltip from '$lib/components/common/Tooltip.svelte';
  30. import RateComment from './RateComment.svelte';
  31. import Spinner from '$lib/components/common/Spinner.svelte';
  32. import WebSearchResults from './ResponseMessage/WebSearchResults.svelte';
  33. import Sparkles from '$lib/components/icons/Sparkles.svelte';
  34. import Error from './Error.svelte';
  35. import Citations from './Citations.svelte';
  36. import CodeExecutions from './CodeExecutions.svelte';
  37. import ContentRenderer from './ContentRenderer.svelte';
  38. import { KokoroWorker } from '$lib/workers/KokoroWorker';
  39. interface MessageType {
  40. id: string;
  41. model: string;
  42. content: string;
  43. files?: { type: string; url: string }[];
  44. timestamp: number;
  45. role: string;
  46. statusHistory?: {
  47. done: boolean;
  48. action: string;
  49. description: string;
  50. urls?: string[];
  51. query?: string;
  52. }[];
  53. status?: {
  54. done: boolean;
  55. action: string;
  56. description: string;
  57. urls?: string[];
  58. query?: string;
  59. };
  60. done: boolean;
  61. error?: boolean | { content: string };
  62. sources?: string[];
  63. code_executions?: {
  64. uuid: string;
  65. name: string;
  66. code: string;
  67. language?: string;
  68. result?: {
  69. error?: string;
  70. output?: string;
  71. files?: { name: string; url: string }[];
  72. };
  73. }[];
  74. info?: {
  75. openai?: boolean;
  76. prompt_tokens?: number;
  77. completion_tokens?: number;
  78. total_tokens?: number;
  79. eval_count?: number;
  80. eval_duration?: number;
  81. prompt_eval_count?: number;
  82. prompt_eval_duration?: number;
  83. total_duration?: number;
  84. load_duration?: number;
  85. usage?: unknown;
  86. };
  87. annotation?: { type: string; rating: number };
  88. }
  89. export let chatId = '';
  90. export let history;
  91. export let messageId;
  92. let message: MessageType = JSON.parse(JSON.stringify(history.messages[messageId]));
  93. $: if (history.messages) {
  94. if (JSON.stringify(message) !== JSON.stringify(history.messages[messageId])) {
  95. message = JSON.parse(JSON.stringify(history.messages[messageId]));
  96. }
  97. }
  98. export let siblings;
  99. export let showPreviousMessage: Function;
  100. export let showNextMessage: Function;
  101. export let updateChat: Function;
  102. export let editMessage: Function;
  103. export let saveMessage: Function;
  104. export let rateMessage: Function;
  105. export let actionMessage: Function;
  106. export let deleteMessage: Function;
  107. export let submitMessage: Function;
  108. export let continueResponse: Function;
  109. export let regenerateResponse: Function;
  110. export let addMessages: Function;
  111. export let isLastMessage = true;
  112. export let readOnly = false;
  113. let model = null;
  114. $: model = $models.find((m) => m.id === message.model);
  115. let edit = false;
  116. let editedContent = '';
  117. let editTextAreaElement: HTMLTextAreaElement;
  118. let audioParts: Record<number, HTMLAudioElement | null> = {};
  119. let speaking = false;
  120. let speakingIdx: number | undefined;
  121. let loadingSpeech = false;
  122. let generatingImage = false;
  123. let showRateComment = false;
  124. const copyToClipboard = async (text) => {
  125. const res = await _copyToClipboard(text);
  126. if (res) {
  127. toast.success($i18n.t('Copying to clipboard was successful!'));
  128. }
  129. };
  130. const playAudio = (idx: number) => {
  131. return new Promise<void>((res) => {
  132. speakingIdx = idx;
  133. const audio = audioParts[idx];
  134. if (!audio) {
  135. return res();
  136. }
  137. audio.play();
  138. audio.onended = async () => {
  139. await new Promise((r) => setTimeout(r, 300));
  140. if (Object.keys(audioParts).length - 1 === idx) {
  141. speaking = false;
  142. }
  143. res();
  144. };
  145. });
  146. };
  147. const toggleSpeakMessage = async () => {
  148. if (speaking) {
  149. try {
  150. speechSynthesis.cancel();
  151. if (speakingIdx !== undefined && audioParts[speakingIdx]) {
  152. audioParts[speakingIdx]!.pause();
  153. audioParts[speakingIdx]!.currentTime = 0;
  154. }
  155. } catch {}
  156. speaking = false;
  157. speakingIdx = undefined;
  158. return;
  159. }
  160. if (!(message?.content ?? '').trim().length) {
  161. toast.info($i18n.t('No content to speak'));
  162. return;
  163. }
  164. speaking = true;
  165. if ($config.audio.tts.engine === '') {
  166. let voices = [];
  167. const getVoicesLoop = setInterval(() => {
  168. voices = speechSynthesis.getVoices();
  169. if (voices.length > 0) {
  170. clearInterval(getVoicesLoop);
  171. const voice =
  172. voices
  173. ?.filter(
  174. (v) => v.voiceURI === ($settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice)
  175. )
  176. ?.at(0) ?? undefined;
  177. console.log(voice);
  178. const speak = new SpeechSynthesisUtterance(message.content);
  179. speak.rate = $settings.audio?.tts?.playbackRate ?? 1;
  180. console.log(speak);
  181. speak.onend = () => {
  182. speaking = false;
  183. if ($settings.conversationMode) {
  184. document.getElementById('voice-input-button')?.click();
  185. }
  186. };
  187. if (voice) {
  188. speak.voice = voice;
  189. }
  190. speechSynthesis.speak(speak);
  191. }
  192. }, 100);
  193. } else {
  194. loadingSpeech = true;
  195. const messageContentParts: string[] = getMessageContentParts(
  196. message.content,
  197. $config?.audio?.tts?.split_on ?? 'punctuation'
  198. );
  199. if (!messageContentParts.length) {
  200. console.log('No content to speak');
  201. toast.info($i18n.t('No content to speak'));
  202. speaking = false;
  203. loadingSpeech = false;
  204. return;
  205. }
  206. console.debug('Prepared message content for TTS', messageContentParts);
  207. audioParts = messageContentParts.reduce(
  208. (acc, _sentence, idx) => {
  209. acc[idx] = null;
  210. return acc;
  211. },
  212. {} as typeof audioParts
  213. );
  214. let lastPlayedAudioPromise = Promise.resolve(); // Initialize a promise that resolves immediately
  215. if ($settings.audio?.tts?.engine === 'browser-kokoro') {
  216. if (!$TTSWorker) {
  217. await TTSWorker.set(
  218. new KokoroWorker({
  219. dtype: $settings.audio?.tts?.engineConfig?.dtype ?? 'fp32'
  220. })
  221. );
  222. await $TTSWorker.init();
  223. }
  224. console.log($TTSWorker);
  225. for (const [idx, sentence] of messageContentParts.entries()) {
  226. const blob = await $TTSWorker
  227. .generate({
  228. text: sentence,
  229. voice: $settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice
  230. })
  231. .catch((error) => {
  232. console.error(error);
  233. toast.error(`${error}`);
  234. speaking = false;
  235. loadingSpeech = false;
  236. });
  237. if (blob) {
  238. const audio = new Audio(blob);
  239. audio.playbackRate = $settings.audio?.tts?.playbackRate ?? 1;
  240. audioParts[idx] = audio;
  241. loadingSpeech = false;
  242. lastPlayedAudioPromise = lastPlayedAudioPromise.then(() => playAudio(idx));
  243. }
  244. }
  245. } else {
  246. for (const [idx, sentence] of messageContentParts.entries()) {
  247. const res = await synthesizeOpenAISpeech(
  248. localStorage.token,
  249. $settings?.audio?.tts?.defaultVoice === $config.audio.tts.voice
  250. ? ($settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice)
  251. : $config?.audio?.tts?.voice,
  252. sentence
  253. ).catch((error) => {
  254. console.error(error);
  255. toast.error(`${error}`);
  256. speaking = false;
  257. loadingSpeech = false;
  258. });
  259. if (res) {
  260. const blob = await res.blob();
  261. const blobUrl = URL.createObjectURL(blob);
  262. const audio = new Audio(blobUrl);
  263. audio.playbackRate = $settings.audio?.tts?.playbackRate ?? 1;
  264. audioParts[idx] = audio;
  265. loadingSpeech = false;
  266. lastPlayedAudioPromise = lastPlayedAudioPromise.then(() => playAudio(idx));
  267. }
  268. }
  269. }
  270. }
  271. };
  272. const editMessageHandler = async () => {
  273. edit = true;
  274. editedContent = message.content;
  275. await tick();
  276. editTextAreaElement.style.height = '';
  277. editTextAreaElement.style.height = `${editTextAreaElement.scrollHeight}px`;
  278. };
  279. const editMessageConfirmHandler = async () => {
  280. editMessage(message.id, editedContent ? editedContent : '', false);
  281. edit = false;
  282. editedContent = '';
  283. await tick();
  284. };
  285. const saveAsCopyHandler = async () => {
  286. editMessage(message.id, editedContent ? editedContent : '');
  287. edit = false;
  288. editedContent = '';
  289. await tick();
  290. };
  291. const cancelEditMessage = async () => {
  292. edit = false;
  293. editedContent = '';
  294. await tick();
  295. };
  296. const generateImage = async (message: MessageType) => {
  297. generatingImage = true;
  298. const res = await imageGenerations(localStorage.token, message.content).catch((error) => {
  299. toast.error(`${error}`);
  300. });
  301. console.log(res);
  302. if (res) {
  303. const files = res.map((image) => ({
  304. type: 'image',
  305. url: `${image.url}`
  306. }));
  307. saveMessage(message.id, {
  308. ...message,
  309. files: files
  310. });
  311. }
  312. generatingImage = false;
  313. };
  314. let feedbackLoading = false;
  315. const feedbackHandler = async (rating: number | null = null, details: object | null = null) => {
  316. feedbackLoading = true;
  317. console.log('Feedback', rating, details);
  318. const updatedMessage = {
  319. ...message,
  320. annotation: {
  321. ...(message?.annotation ?? {}),
  322. ...(rating !== null ? { rating: rating } : {}),
  323. ...(details ? details : {})
  324. }
  325. };
  326. const chat = await getChatById(localStorage.token, chatId).catch((error) => {
  327. toast.error(`${error}`);
  328. });
  329. if (!chat) {
  330. return;
  331. }
  332. const messages = createMessagesList(history, message.id);
  333. let feedbackItem = {
  334. type: 'rating',
  335. data: {
  336. ...(updatedMessage?.annotation ? updatedMessage.annotation : {}),
  337. model_id: message?.selectedModelId ?? message.model,
  338. ...(history.messages[message.parentId].childrenIds.length > 1
  339. ? {
  340. sibling_model_ids: history.messages[message.parentId].childrenIds
  341. .filter((id) => id !== message.id)
  342. .map((id) => history.messages[id]?.selectedModelId ?? history.messages[id].model)
  343. }
  344. : {})
  345. },
  346. meta: {
  347. arena: message ? message.arena : false,
  348. model_id: message.model,
  349. message_id: message.id,
  350. message_index: messages.length,
  351. chat_id: chatId
  352. },
  353. snapshot: {
  354. chat: chat
  355. }
  356. };
  357. const baseModels = [
  358. feedbackItem.data.model_id,
  359. ...(feedbackItem.data.sibling_model_ids ?? [])
  360. ].reduce((acc, modelId) => {
  361. const model = $models.find((m) => m.id === modelId);
  362. if (model) {
  363. acc[model.id] = model?.info?.base_model_id ?? null;
  364. } else {
  365. // Log or handle cases where corresponding model is not found
  366. console.warn(`Model with ID ${modelId} not found`);
  367. }
  368. return acc;
  369. }, {});
  370. feedbackItem.meta.base_models = baseModels;
  371. let feedback = null;
  372. if (message?.feedbackId) {
  373. feedback = await updateFeedbackById(
  374. localStorage.token,
  375. message.feedbackId,
  376. feedbackItem
  377. ).catch((error) => {
  378. toast.error(`${error}`);
  379. });
  380. } else {
  381. feedback = await createNewFeedback(localStorage.token, feedbackItem).catch((error) => {
  382. toast.error(`${error}`);
  383. });
  384. if (feedback) {
  385. updatedMessage.feedbackId = feedback.id;
  386. }
  387. }
  388. console.log(updatedMessage);
  389. saveMessage(message.id, updatedMessage);
  390. await tick();
  391. if (!details) {
  392. showRateComment = true;
  393. if (!updatedMessage.annotation?.tags) {
  394. // attempt to generate tags
  395. const tags = await generateTags(localStorage.token, message.model, messages, chatId).catch(
  396. (error) => {
  397. console.error(error);
  398. return [];
  399. }
  400. );
  401. console.log(tags);
  402. if (tags) {
  403. updatedMessage.annotation.tags = tags;
  404. feedbackItem.data.tags = tags;
  405. saveMessage(message.id, updatedMessage);
  406. await updateFeedbackById(
  407. localStorage.token,
  408. updatedMessage.feedbackId,
  409. feedbackItem
  410. ).catch((error) => {
  411. toast.error(`${error}`);
  412. });
  413. }
  414. }
  415. }
  416. feedbackLoading = false;
  417. };
  418. const deleteMessageHandler = async () => {
  419. deleteMessage(message.id);
  420. };
  421. $: if (!edit) {
  422. (async () => {
  423. await tick();
  424. })();
  425. }
  426. onMount(async () => {
  427. // console.log('ResponseMessage mounted');
  428. await tick();
  429. });
  430. </script>
  431. {#key message.id}
  432. <div
  433. class=" flex w-full message-{message.id}"
  434. id="message-{message.id}"
  435. dir={$settings.chatDirection}
  436. >
  437. <div class={`flex-shrink-0 ${($settings?.chatDirection ?? 'LTR') === 'LTR' ? 'mr-3' : 'ml-3'}`}>
  438. <ProfileImage
  439. src={model?.info?.meta?.profile_image_url ??
  440. ($i18n.language === 'dg-DG' ? `/doge.png` : `${WEBUI_BASE_URL}/static/favicon.png`)}
  441. className={'size-8'}
  442. />
  443. </div>
  444. <div class="flex-auto w-0 pl-1">
  445. <Name>
  446. <Tooltip content={model?.name ?? message.model} placement="top-start">
  447. <span class="line-clamp-1">
  448. {model?.name ?? message.model}
  449. </span>
  450. </Tooltip>
  451. {#if message.timestamp}
  452. <div
  453. class=" self-center text-xs invisible group-hover:visible text-gray-400 font-medium first-letter:capitalize ml-0.5 translate-y-[1px]"
  454. >
  455. <Tooltip content={dayjs(message.timestamp * 1000).format('LLLL')}>
  456. <span class="line-clamp-1">{formatDate(message.timestamp * 1000)}</span>
  457. </Tooltip>
  458. </div>
  459. {/if}
  460. </Name>
  461. <div>
  462. {#if message?.files && message.files?.filter((f) => f.type === 'image').length > 0}
  463. <div class="my-2.5 w-full flex overflow-x-auto gap-2 flex-wrap">
  464. {#each message.files as file}
  465. <div>
  466. {#if file.type === 'image'}
  467. <Image src={file.url} alt={message.content} />
  468. {/if}
  469. </div>
  470. {/each}
  471. </div>
  472. {/if}
  473. <div class="chat-{message.role} w-full min-w-full markdown-prose">
  474. <div>
  475. {#if (message?.statusHistory ?? [...(message?.status ? [message?.status] : [])]).length > 0}
  476. {@const status = (
  477. message?.statusHistory ?? [...(message?.status ? [message?.status] : [])]
  478. ).at(-1)}
  479. {#if !status?.hidden}
  480. <div class="status-description flex items-center gap-2 py-0.5">
  481. {#if status?.done === false}
  482. <div class="">
  483. <Spinner className="size-4" />
  484. </div>
  485. {/if}
  486. {#if status?.action === 'web_search' && status?.urls}
  487. <WebSearchResults {status}>
  488. <div class="flex flex-col justify-center -space-y-0.5">
  489. <div
  490. class="{status?.done === false
  491. ? 'shimmer'
  492. : ''} text-base line-clamp-1 text-wrap"
  493. >
  494. <!-- $i18n.t("Generating search query") -->
  495. <!-- $i18n.t("No search query generated") -->
  496. <!-- $i18n.t('Searched {{count}} sites') -->
  497. {#if status?.description.includes('{{count}}')}
  498. {$i18n.t(status?.description, {
  499. count: status?.urls.length
  500. })}
  501. {:else if status?.description === 'No search query generated'}
  502. {$i18n.t('No search query generated')}
  503. {:else if status?.description === 'Generating search query'}
  504. {$i18n.t('Generating search query')}
  505. {:else}
  506. {status?.description}
  507. {/if}
  508. </div>
  509. </div>
  510. </WebSearchResults>
  511. {:else if status?.action === 'knowledge_search'}
  512. <div class="flex flex-col justify-center -space-y-0.5">
  513. <div
  514. class="{status?.done === false
  515. ? 'shimmer'
  516. : ''} text-gray-500 dark:text-gray-500 text-base line-clamp-1 text-wrap"
  517. >
  518. {$i18n.t(`Searching Knowledge for "{{searchQuery}}"`, {
  519. searchQuery: status.query
  520. })}
  521. </div>
  522. </div>
  523. {:else}
  524. <div class="flex flex-col justify-center -space-y-0.5">
  525. <div
  526. class="{status?.done === false
  527. ? 'shimmer'
  528. : ''} text-gray-500 dark:text-gray-500 text-base line-clamp-1 text-wrap"
  529. >
  530. <!-- $i18n.t(`Searching "{{searchQuery}}"`) -->
  531. {#if status?.description.includes('{{searchQuery}}')}
  532. {$i18n.t(status?.description, {
  533. searchQuery: status?.query
  534. })}
  535. {:else if status?.description === 'No search query generated'}
  536. {$i18n.t('No search query generated')}
  537. {:else if status?.description === 'Generating search query'}
  538. {$i18n.t('Generating search query')}
  539. {:else}
  540. {status?.description}
  541. {/if}
  542. </div>
  543. </div>
  544. {/if}
  545. </div>
  546. {/if}
  547. {/if}
  548. {#if edit === true}
  549. <div class="w-full bg-gray-50 dark:bg-gray-800 rounded-3xl px-5 py-3 my-2">
  550. <textarea
  551. id="message-edit-{message.id}"
  552. bind:this={editTextAreaElement}
  553. class=" bg-transparent outline-none w-full resize-none"
  554. bind:value={editedContent}
  555. on:input={(e) => {
  556. e.target.style.height = '';
  557. e.target.style.height = `${e.target.scrollHeight}px`;
  558. }}
  559. on:keydown={(e) => {
  560. if (e.key === 'Escape') {
  561. document.getElementById('close-edit-message-button')?.click();
  562. }
  563. const isCmdOrCtrlPressed = e.metaKey || e.ctrlKey;
  564. const isEnterPressed = e.key === 'Enter';
  565. if (isCmdOrCtrlPressed && isEnterPressed) {
  566. document.getElementById('confirm-edit-message-button')?.click();
  567. }
  568. }}
  569. />
  570. <div class=" mt-2 mb-1 flex justify-between text-sm font-medium">
  571. <div>
  572. <button
  573. id="save-new-message-button"
  574. class=" px-4 py-2 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 border dark:border-gray-700 text-gray-700 dark:text-gray-200 transition rounded-3xl"
  575. on:click={() => {
  576. saveAsCopyHandler();
  577. }}
  578. >
  579. {$i18n.t('Save As Copy')}
  580. </button>
  581. </div>
  582. <div class="flex space-x-1.5">
  583. <button
  584. id="close-edit-message-button"
  585. class="px-4 py-2 bg-white dark:bg-gray-900 hover:bg-gray-100 text-gray-800 dark:text-gray-100 transition rounded-3xl"
  586. on:click={() => {
  587. cancelEditMessage();
  588. }}
  589. >
  590. {$i18n.t('Cancel')}
  591. </button>
  592. <button
  593. id="confirm-edit-message-button"
  594. class=" px-4 py-2 bg-gray-900 dark:bg-white hover:bg-gray-850 text-gray-100 dark:text-gray-800 transition rounded-3xl"
  595. on:click={() => {
  596. editMessageConfirmHandler();
  597. }}
  598. >
  599. {$i18n.t('Save')}
  600. </button>
  601. </div>
  602. </div>
  603. </div>
  604. {:else}
  605. <div class="w-full flex flex-col relative" id="response-content-container">
  606. {#if message.content === '' && !message.error}
  607. <Skeleton />
  608. {:else if message.content && message.error !== true}
  609. <!-- always show message contents even if there's an error -->
  610. <!-- unless message.error === true which is legacy error handling, where the error message is stored in message.content -->
  611. <ContentRenderer
  612. id={message.id}
  613. {history}
  614. content={message.content}
  615. sources={message.sources}
  616. floatingButtons={message?.done}
  617. save={!readOnly}
  618. {model}
  619. onSourceClick={(e) => {
  620. console.log(e);
  621. const sourceButton = document.getElementById(`source-${e}`);
  622. if (sourceButton) {
  623. sourceButton.click();
  624. }
  625. }}
  626. onAddMessages={({ modelId, parentId, messages }) => {
  627. addMessages({ modelId, parentId, messages });
  628. }}
  629. on:update={(e) => {
  630. const { raw, oldContent, newContent } = e.detail;
  631. history.messages[message.id].content = history.messages[
  632. message.id
  633. ].content.replace(raw, raw.replace(oldContent, newContent));
  634. updateChat();
  635. }}
  636. on:select={(e) => {
  637. const { type, content } = e.detail;
  638. if (type === 'explain') {
  639. submitMessage(
  640. message.id,
  641. `Explain this section to me in more detail\n\n\`\`\`\n${content}\n\`\`\``
  642. );
  643. } else if (type === 'ask') {
  644. const input = e.detail?.input ?? '';
  645. submitMessage(message.id, `\`\`\`\n${content}\n\`\`\`\n${input}`);
  646. }
  647. }}
  648. />
  649. {/if}
  650. {#if message?.error}
  651. <Error content={message?.error?.content ?? message.content} />
  652. {/if}
  653. {#if (message?.sources || message?.citations) && (model?.info?.meta?.capabilities?.citations ?? true)}
  654. <Citations sources={message?.sources ?? message?.citations} />
  655. {/if}
  656. {#if message.code_executions}
  657. <CodeExecutions codeExecutions={message.code_executions} />
  658. {/if}
  659. </div>
  660. {/if}
  661. </div>
  662. </div>
  663. {#if !edit}
  664. {#if message.done || siblings.length > 1}
  665. <div
  666. class=" flex justify-start overflow-x-auto buttons text-gray-600 dark:text-gray-500 mt-0.5"
  667. >
  668. {#if siblings.length > 1}
  669. <div class="flex self-center min-w-fit" dir="ltr">
  670. <button
  671. class="self-center p-1 hover:bg-black/5 dark:hover:bg-white/5 dark:hover:text-white hover:text-black rounded-md transition"
  672. on:click={() => {
  673. showPreviousMessage(message);
  674. }}
  675. >
  676. <svg
  677. xmlns="http://www.w3.org/2000/svg"
  678. fill="none"
  679. viewBox="0 0 24 24"
  680. stroke="currentColor"
  681. stroke-width="2.5"
  682. class="size-3.5"
  683. >
  684. <path
  685. stroke-linecap="round"
  686. stroke-linejoin="round"
  687. d="M15.75 19.5 8.25 12l7.5-7.5"
  688. />
  689. </svg>
  690. </button>
  691. <div
  692. class="text-sm tracking-widest font-semibold self-center dark:text-gray-100 min-w-fit"
  693. >
  694. {siblings.indexOf(message.id) + 1}/{siblings.length}
  695. </div>
  696. <button
  697. class="self-center p-1 hover:bg-black/5 dark:hover:bg-white/5 dark:hover:text-white hover:text-black rounded-md transition"
  698. on:click={() => {
  699. showNextMessage(message);
  700. }}
  701. >
  702. <svg
  703. xmlns="http://www.w3.org/2000/svg"
  704. fill="none"
  705. viewBox="0 0 24 24"
  706. stroke="currentColor"
  707. stroke-width="2.5"
  708. class="size-3.5"
  709. >
  710. <path
  711. stroke-linecap="round"
  712. stroke-linejoin="round"
  713. d="m8.25 4.5 7.5 7.5-7.5 7.5"
  714. />
  715. </svg>
  716. </button>
  717. </div>
  718. {/if}
  719. {#if message.done}
  720. {#if !readOnly}
  721. {#if $user.role === 'user' ? ($user?.permissions?.chat?.edit ?? true) : true}
  722. <Tooltip content={$i18n.t('Edit')} placement="bottom">
  723. <button
  724. class="{isLastMessage
  725. ? 'visible'
  726. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition"
  727. on:click={() => {
  728. editMessageHandler();
  729. }}
  730. >
  731. <svg
  732. xmlns="http://www.w3.org/2000/svg"
  733. fill="none"
  734. viewBox="0 0 24 24"
  735. stroke-width="2.3"
  736. stroke="currentColor"
  737. class="w-4 h-4"
  738. >
  739. <path
  740. stroke-linecap="round"
  741. stroke-linejoin="round"
  742. d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"
  743. />
  744. </svg>
  745. </button>
  746. </Tooltip>
  747. {/if}
  748. {/if}
  749. <Tooltip content={$i18n.t('Copy')} placement="bottom">
  750. <button
  751. class="{isLastMessage
  752. ? 'visible'
  753. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition copy-response-button"
  754. on:click={() => {
  755. copyToClipboard(message.content);
  756. }}
  757. >
  758. <svg
  759. xmlns="http://www.w3.org/2000/svg"
  760. fill="none"
  761. viewBox="0 0 24 24"
  762. stroke-width="2.3"
  763. stroke="currentColor"
  764. class="w-4 h-4"
  765. >
  766. <path
  767. stroke-linecap="round"
  768. stroke-linejoin="round"
  769. d="M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"
  770. />
  771. </svg>
  772. </button>
  773. </Tooltip>
  774. <Tooltip content={$i18n.t('Read Aloud')} placement="bottom">
  775. <button
  776. id="speak-button-{message.id}"
  777. class="{isLastMessage
  778. ? 'visible'
  779. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition"
  780. on:click={() => {
  781. if (!loadingSpeech) {
  782. toggleSpeakMessage();
  783. }
  784. }}
  785. >
  786. {#if loadingSpeech}
  787. <svg
  788. class=" w-4 h-4"
  789. fill="currentColor"
  790. viewBox="0 0 24 24"
  791. xmlns="http://www.w3.org/2000/svg"
  792. >
  793. <style>
  794. .spinner_S1WN {
  795. animation: spinner_MGfb 0.8s linear infinite;
  796. animation-delay: -0.8s;
  797. }
  798. .spinner_Km9P {
  799. animation-delay: -0.65s;
  800. }
  801. .spinner_JApP {
  802. animation-delay: -0.5s;
  803. }
  804. @keyframes spinner_MGfb {
  805. 93.75%,
  806. 100% {
  807. opacity: 0.2;
  808. }
  809. }
  810. </style>
  811. <circle class="spinner_S1WN" cx="4" cy="12" r="3" />
  812. <circle class="spinner_S1WN spinner_Km9P" cx="12" cy="12" r="3" />
  813. <circle class="spinner_S1WN spinner_JApP" cx="20" cy="12" r="3" />
  814. </svg>
  815. {:else if speaking}
  816. <svg
  817. xmlns="http://www.w3.org/2000/svg"
  818. fill="none"
  819. viewBox="0 0 24 24"
  820. stroke-width="2.3"
  821. stroke="currentColor"
  822. class="w-4 h-4"
  823. >
  824. <path
  825. stroke-linecap="round"
  826. stroke-linejoin="round"
  827. d="M17.25 9.75 19.5 12m0 0 2.25 2.25M19.5 12l2.25-2.25M19.5 12l-2.25 2.25m-10.5-6 4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"
  828. />
  829. </svg>
  830. {:else}
  831. <svg
  832. xmlns="http://www.w3.org/2000/svg"
  833. fill="none"
  834. viewBox="0 0 24 24"
  835. stroke-width="2.3"
  836. stroke="currentColor"
  837. class="w-4 h-4"
  838. >
  839. <path
  840. stroke-linecap="round"
  841. stroke-linejoin="round"
  842. d="M19.114 5.636a9 9 0 010 12.728M16.463 8.288a5.25 5.25 0 010 7.424M6.75 8.25l4.72-4.72a.75.75 0 011.28.53v15.88a.75.75 0 01-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.01 9.01 0 012.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75z"
  843. />
  844. </svg>
  845. {/if}
  846. </button>
  847. </Tooltip>
  848. {#if $config?.features.enable_image_generation && ($user.role === 'admin' || $user?.permissions?.features?.image_generation) && !readOnly}
  849. <Tooltip content={$i18n.t('Generate Image')} placement="bottom">
  850. <button
  851. class="{isLastMessage
  852. ? 'visible'
  853. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition"
  854. on:click={() => {
  855. if (!generatingImage) {
  856. generateImage(message);
  857. }
  858. }}
  859. >
  860. {#if generatingImage}
  861. <svg
  862. class=" w-4 h-4"
  863. fill="currentColor"
  864. viewBox="0 0 24 24"
  865. xmlns="http://www.w3.org/2000/svg"
  866. >
  867. <style>
  868. .spinner_S1WN {
  869. animation: spinner_MGfb 0.8s linear infinite;
  870. animation-delay: -0.8s;
  871. }
  872. .spinner_Km9P {
  873. animation-delay: -0.65s;
  874. }
  875. .spinner_JApP {
  876. animation-delay: -0.5s;
  877. }
  878. @keyframes spinner_MGfb {
  879. 93.75%,
  880. 100% {
  881. opacity: 0.2;
  882. }
  883. }
  884. </style>
  885. <circle class="spinner_S1WN" cx="4" cy="12" r="3" />
  886. <circle class="spinner_S1WN spinner_Km9P" cx="12" cy="12" r="3" />
  887. <circle class="spinner_S1WN spinner_JApP" cx="20" cy="12" r="3" />
  888. </svg>
  889. {:else}
  890. <svg
  891. xmlns="http://www.w3.org/2000/svg"
  892. fill="none"
  893. viewBox="0 0 24 24"
  894. stroke-width="2.3"
  895. stroke="currentColor"
  896. class="w-4 h-4"
  897. >
  898. <path
  899. stroke-linecap="round"
  900. stroke-linejoin="round"
  901. d="m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"
  902. />
  903. </svg>
  904. {/if}
  905. </button>
  906. </Tooltip>
  907. {/if}
  908. {#if message.usage}
  909. <Tooltip
  910. content={message.usage
  911. ? `<pre>${sanitizeResponseContent(
  912. JSON.stringify(message.usage, null, 2)
  913. .replace(/"([^(")"]+)":/g, '$1:')
  914. .slice(1, -1)
  915. .split('\n')
  916. .map((line) => line.slice(2))
  917. .map((line) => (line.endsWith(',') ? line.slice(0, -1) : line))
  918. .join('\n')
  919. )}</pre>`
  920. : ''}
  921. placement="bottom"
  922. >
  923. <button
  924. class=" {isLastMessage
  925. ? 'visible'
  926. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition whitespace-pre-wrap"
  927. on:click={() => {
  928. console.log(message);
  929. }}
  930. id="info-{message.id}"
  931. >
  932. <svg
  933. xmlns="http://www.w3.org/2000/svg"
  934. fill="none"
  935. viewBox="0 0 24 24"
  936. stroke-width="2.3"
  937. stroke="currentColor"
  938. class="w-4 h-4"
  939. >
  940. <path
  941. stroke-linecap="round"
  942. stroke-linejoin="round"
  943. d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"
  944. />
  945. </svg>
  946. </button>
  947. </Tooltip>
  948. {/if}
  949. {#if !readOnly}
  950. {#if $config?.features.enable_message_rating ?? true}
  951. <Tooltip content={$i18n.t('Good Response')} placement="bottom">
  952. <button
  953. class="{isLastMessage
  954. ? 'visible'
  955. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg {(
  956. message?.annotation?.rating ?? ''
  957. ).toString() === '1'
  958. ? 'bg-gray-100 dark:bg-gray-800'
  959. : ''} dark:hover:text-white hover:text-black transition disabled:cursor-progress disabled:hover:bg-transparent"
  960. disabled={feedbackLoading}
  961. on:click={async () => {
  962. await feedbackHandler(1);
  963. window.setTimeout(() => {
  964. document
  965. .getElementById(`message-feedback-${message.id}`)
  966. ?.scrollIntoView();
  967. }, 0);
  968. }}
  969. >
  970. <svg
  971. stroke="currentColor"
  972. fill="none"
  973. stroke-width="2.3"
  974. viewBox="0 0 24 24"
  975. stroke-linecap="round"
  976. stroke-linejoin="round"
  977. class="w-4 h-4"
  978. xmlns="http://www.w3.org/2000/svg"
  979. >
  980. <path
  981. d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"
  982. />
  983. </svg>
  984. </button>
  985. </Tooltip>
  986. <Tooltip content={$i18n.t('Bad Response')} placement="bottom">
  987. <button
  988. class="{isLastMessage
  989. ? 'visible'
  990. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg {(
  991. message?.annotation?.rating ?? ''
  992. ).toString() === '-1'
  993. ? 'bg-gray-100 dark:bg-gray-800'
  994. : ''} dark:hover:text-white hover:text-black transition disabled:cursor-progress disabled:hover:bg-transparent"
  995. disabled={feedbackLoading}
  996. on:click={async () => {
  997. await feedbackHandler(-1);
  998. window.setTimeout(() => {
  999. document
  1000. .getElementById(`message-feedback-${message.id}`)
  1001. ?.scrollIntoView();
  1002. }, 0);
  1003. }}
  1004. >
  1005. <svg
  1006. stroke="currentColor"
  1007. fill="none"
  1008. stroke-width="2.3"
  1009. viewBox="0 0 24 24"
  1010. stroke-linecap="round"
  1011. stroke-linejoin="round"
  1012. class="w-4 h-4"
  1013. xmlns="http://www.w3.org/2000/svg"
  1014. >
  1015. <path
  1016. d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"
  1017. />
  1018. </svg>
  1019. </button>
  1020. </Tooltip>
  1021. {/if}
  1022. {#if isLastMessage}
  1023. <Tooltip content={$i18n.t('Continue Response')} placement="bottom">
  1024. <button
  1025. type="button"
  1026. id="continue-response-button"
  1027. class="{isLastMessage
  1028. ? 'visible'
  1029. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
  1030. on:click={() => {
  1031. continueResponse();
  1032. }}
  1033. >
  1034. <svg
  1035. xmlns="http://www.w3.org/2000/svg"
  1036. fill="none"
  1037. viewBox="0 0 24 24"
  1038. stroke-width="2.3"
  1039. stroke="currentColor"
  1040. class="w-4 h-4"
  1041. >
  1042. <path
  1043. stroke-linecap="round"
  1044. stroke-linejoin="round"
  1045. d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
  1046. />
  1047. <path
  1048. stroke-linecap="round"
  1049. stroke-linejoin="round"
  1050. d="M15.91 11.672a.375.375 0 0 1 0 .656l-5.603 3.113a.375.375 0 0 1-.557-.328V8.887c0-.286.307-.466.557-.327l5.603 3.112Z"
  1051. />
  1052. </svg>
  1053. </button>
  1054. </Tooltip>
  1055. {/if}
  1056. <Tooltip content={$i18n.t('Regenerate')} placement="bottom">
  1057. <button
  1058. type="button"
  1059. class="{isLastMessage
  1060. ? 'visible'
  1061. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
  1062. on:click={() => {
  1063. showRateComment = false;
  1064. regenerateResponse(message);
  1065. (model?.actions ?? []).forEach((action) => {
  1066. dispatch('action', {
  1067. id: action.id,
  1068. event: {
  1069. id: 'regenerate-response',
  1070. data: {
  1071. messageId: message.id
  1072. }
  1073. }
  1074. });
  1075. });
  1076. }}
  1077. >
  1078. <svg
  1079. xmlns="http://www.w3.org/2000/svg"
  1080. fill="none"
  1081. viewBox="0 0 24 24"
  1082. stroke-width="2.3"
  1083. stroke="currentColor"
  1084. class="w-4 h-4"
  1085. >
  1086. <path
  1087. stroke-linecap="round"
  1088. stroke-linejoin="round"
  1089. d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
  1090. />
  1091. </svg>
  1092. </button>
  1093. </Tooltip>
  1094. {#if siblings.length > 1}
  1095. <Tooltip content={$i18n.t('Delete')} placement="bottom">
  1096. <button
  1097. type="button"
  1098. id="continue-response-button"
  1099. class="{isLastMessage
  1100. ? 'visible'
  1101. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
  1102. on:click={() => {
  1103. deleteMessageHandler();
  1104. }}
  1105. >
  1106. <svg
  1107. xmlns="http://www.w3.org/2000/svg"
  1108. fill="none"
  1109. viewBox="0 0 24 24"
  1110. stroke-width="2"
  1111. stroke="currentColor"
  1112. class="w-4 h-4"
  1113. >
  1114. <path
  1115. stroke-linecap="round"
  1116. stroke-linejoin="round"
  1117. d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"
  1118. />
  1119. </svg>
  1120. </button>
  1121. </Tooltip>
  1122. {/if}
  1123. {#if isLastMessage}
  1124. {#each model?.actions ?? [] as action}
  1125. <Tooltip content={action.name} placement="bottom">
  1126. <button
  1127. type="button"
  1128. class="{isLastMessage
  1129. ? 'visible'
  1130. : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition"
  1131. on:click={() => {
  1132. actionMessage(action.id, message);
  1133. }}
  1134. >
  1135. {#if action.icon_url}
  1136. <div class="size-4">
  1137. <img
  1138. src={action.icon_url}
  1139. class="w-4 h-4 {action.icon_url.includes('svg')
  1140. ? 'dark:invert-[80%]'
  1141. : ''}"
  1142. style="fill: currentColor;"
  1143. alt={action.name}
  1144. />
  1145. </div>
  1146. {:else}
  1147. <Sparkles strokeWidth="2.1" className="size-4" />
  1148. {/if}
  1149. </button>
  1150. </Tooltip>
  1151. {/each}
  1152. {/if}
  1153. {/if}
  1154. {/if}
  1155. </div>
  1156. {/if}
  1157. {#if message.done && showRateComment}
  1158. <RateComment
  1159. bind:message
  1160. bind:show={showRateComment}
  1161. on:save={async (e) => {
  1162. await feedbackHandler(null, {
  1163. ...e.detail
  1164. });
  1165. }}
  1166. />
  1167. {/if}
  1168. {/if}
  1169. </div>
  1170. </div>
  1171. </div>
  1172. {/key}
  1173. <style>
  1174. .buttons::-webkit-scrollbar {
  1175. display: none; /* for Chrome, Safari and Opera */
  1176. }
  1177. .buttons {
  1178. -ms-overflow-style: none; /* IE and Edge */
  1179. scrollbar-width: none; /* Firefox */
  1180. }
  1181. </style>