ResponseMessage.svelte 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. <script lang="ts">
  2. import toast from 'svelte-french-toast';
  3. import dayjs from 'dayjs';
  4. import { marked } from 'marked';
  5. import { settings } from '$lib/stores';
  6. import tippy from 'tippy.js';
  7. import auto_render from 'katex/dist/contrib/auto-render.mjs';
  8. import 'katex/dist/katex.min.css';
  9. import { onMount, tick } from 'svelte';
  10. import Name from './Name.svelte';
  11. import ProfileImage from './ProfileImage.svelte';
  12. import Skeleton from './Skeleton.svelte';
  13. import CodeBlock from './CodeBlock.svelte';
  14. import { synthesizeOpenAISpeech } from '$lib/apis/openai';
  15. import { extractSentences } from '$lib/utils';
  16. export let modelfiles = [];
  17. export let message;
  18. export let siblings;
  19. export let isLastMessage = true;
  20. export let confirmEditResponseMessage: Function;
  21. export let showPreviousMessage: Function;
  22. export let showNextMessage: Function;
  23. export let rateMessage: Function;
  24. export let copyToClipboard: Function;
  25. export let continueGeneration: Function;
  26. export let regenerateResponse: Function;
  27. let edit = false;
  28. let editedContent = '';
  29. let tooltipInstance = null;
  30. let sentencesAudio = {};
  31. let speaking = null;
  32. let speakingIdx = null;
  33. let loadingSpeech = false;
  34. $: tokens = marked.lexer(message.content);
  35. const renderer = new marked.Renderer();
  36. // For code blocks with simple backticks
  37. renderer.codespan = (code) => {
  38. return `<code>${code.replaceAll('&amp;', '&')}</code>`;
  39. };
  40. const { extensions, ...defaults } = marked.getDefaults() as marked.MarkedOptions & {
  41. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  42. extensions: any;
  43. };
  44. $: if (message) {
  45. renderStyling();
  46. }
  47. const renderStyling = async () => {
  48. await tick();
  49. if (tooltipInstance) {
  50. tooltipInstance[0].destroy();
  51. }
  52. renderLatex();
  53. if (message.info) {
  54. tooltipInstance = tippy(`#info-${message.id}`, {
  55. content: `<span class="text-xs" id="tooltip-${message.id}">token/s: ${
  56. `${
  57. Math.round(
  58. ((message.info.eval_count ?? 0) / (message.info.eval_duration / 1000000000)) * 100
  59. ) / 100
  60. } tokens` ?? 'N/A'
  61. }<br/>
  62. total_duration: ${
  63. Math.round(((message.info.total_duration ?? 0) / 1000000) * 100) / 100 ??
  64. 'N/A'
  65. }ms<br/>
  66. load_duration: ${
  67. Math.round(((message.info.load_duration ?? 0) / 1000000) * 100) / 100 ?? 'N/A'
  68. }ms<br/>
  69. prompt_eval_count: ${message.info.prompt_eval_count ?? 'N/A'}<br/>
  70. prompt_eval_duration: ${
  71. Math.round(((message.info.prompt_eval_duration ?? 0) / 1000000) * 100) /
  72. 100 ?? 'N/A'
  73. }ms<br/>
  74. eval_count: ${message.info.eval_count ?? 'N/A'}<br/>
  75. eval_duration: ${
  76. Math.round(((message.info.eval_duration ?? 0) / 1000000) * 100) / 100 ?? 'N/A'
  77. }ms</span>`,
  78. allowHTML: true
  79. });
  80. }
  81. };
  82. const renderLatex = () => {
  83. let chatMessageElements = document.getElementsByClassName('chat-assistant');
  84. // let lastChatMessageElement = chatMessageElements[chatMessageElements.length - 1];
  85. for (const element of chatMessageElements) {
  86. auto_render(element, {
  87. // customised options
  88. // • auto-render specific keys, e.g.:
  89. delimiters: [
  90. { left: '$$', right: '$$', display: true },
  91. // { left: '$', right: '$', display: false },
  92. { left: '\\(', right: '\\)', display: true },
  93. { left: '\\[', right: '\\]', display: true }
  94. ],
  95. // • rendering keys, e.g.:
  96. throwOnError: false
  97. });
  98. }
  99. };
  100. const playAudio = (idx) => {
  101. return new Promise((res) => {
  102. speakingIdx = idx;
  103. const audio = sentencesAudio[idx];
  104. audio.play();
  105. audio.onended = async (e) => {
  106. await new Promise((r) => setTimeout(r, 300));
  107. if (Object.keys(sentencesAudio).length - 1 === idx) {
  108. speaking = null;
  109. if ($settings.conversationMode) {
  110. document.getElementById('voice-input-button')?.click();
  111. }
  112. }
  113. res(e);
  114. };
  115. });
  116. };
  117. const toggleSpeakMessage = async () => {
  118. if (speaking) {
  119. speechSynthesis.cancel();
  120. sentencesAudio[speakingIdx].pause();
  121. sentencesAudio[speakingIdx].currentTime = 0;
  122. speaking = null;
  123. speakingIdx = null;
  124. } else {
  125. speaking = true;
  126. if ($settings?.audio?.TTSEngine === 'openai') {
  127. loadingSpeech = true;
  128. const sentences = extractSentences(message.content).reduce((mergedTexts, currentText) => {
  129. const lastIndex = mergedTexts.length - 1;
  130. if (lastIndex >= 0) {
  131. const previousText = mergedTexts[lastIndex];
  132. const wordCount = previousText.split(/\s+/).length;
  133. if (wordCount < 2) {
  134. mergedTexts[lastIndex] = previousText + ' ' + currentText;
  135. } else {
  136. mergedTexts.push(currentText);
  137. }
  138. } else {
  139. mergedTexts.push(currentText);
  140. }
  141. return mergedTexts;
  142. }, []);
  143. console.log(sentences);
  144. sentencesAudio = sentences.reduce((a, e, i, arr) => {
  145. a[i] = null;
  146. return a;
  147. }, {});
  148. let lastPlayedAudioPromise = Promise.resolve(); // Initialize a promise that resolves immediately
  149. for (const [idx, sentence] of sentences.entries()) {
  150. const res = await synthesizeOpenAISpeech(
  151. localStorage.token,
  152. $settings?.audio?.speaker,
  153. sentence
  154. ).catch((error) => {
  155. toast.error(error);
  156. return null;
  157. });
  158. if (res) {
  159. const blob = await res.blob();
  160. const blobUrl = URL.createObjectURL(blob);
  161. const audio = new Audio(blobUrl);
  162. sentencesAudio[idx] = audio;
  163. loadingSpeech = false;
  164. lastPlayedAudioPromise = lastPlayedAudioPromise.then(() => playAudio(idx));
  165. }
  166. }
  167. } else {
  168. let voices = [];
  169. const getVoicesLoop = setInterval(async () => {
  170. voices = await speechSynthesis.getVoices();
  171. if (voices.length > 0) {
  172. clearInterval(getVoicesLoop);
  173. const voice =
  174. voices?.filter((v) => v.name === $settings?.audio?.speaker)?.at(0) ?? undefined;
  175. const speak = new SpeechSynthesisUtterance(message.content);
  176. speak.onend = () => {
  177. speaking = null;
  178. if ($settings.conversationMode) {
  179. document.getElementById('voice-input-button')?.click();
  180. }
  181. };
  182. speak.voice = voice;
  183. speechSynthesis.speak(speak);
  184. }
  185. }, 100);
  186. }
  187. }
  188. };
  189. const editMessageHandler = async () => {
  190. edit = true;
  191. editedContent = message.content;
  192. await tick();
  193. const editElement = document.getElementById(`message-edit-${message.id}`);
  194. editElement.style.height = '';
  195. editElement.style.height = `${editElement.scrollHeight}px`;
  196. };
  197. const editMessageConfirmHandler = async () => {
  198. if (editedContent === '') {
  199. editedContent = ' ';
  200. }
  201. confirmEditResponseMessage(message.id, editedContent);
  202. edit = false;
  203. editedContent = '';
  204. await tick();
  205. renderStyling();
  206. };
  207. const cancelEditMessage = async () => {
  208. edit = false;
  209. editedContent = '';
  210. await tick();
  211. renderStyling();
  212. };
  213. onMount(async () => {
  214. await tick();
  215. renderStyling();
  216. });
  217. </script>
  218. {#key message.id}
  219. <div class=" flex w-full message-{message.id}">
  220. <ProfileImage src={modelfiles[message.model]?.imageUrl ?? '/favicon.png'} />
  221. <div class="w-full overflow-hidden">
  222. <Name>
  223. {#if message.model in modelfiles}
  224. {modelfiles[message.model]?.title}
  225. {:else}
  226. {message.model ? ` ${message.model}` : ''}
  227. {/if}
  228. {#if message.timestamp}
  229. <span class=" invisible group-hover:visible text-gray-400 text-xs font-medium">
  230. {dayjs(message.timestamp * 1000).format('DD/MM/YYYY HH:mm')}
  231. </span>
  232. {/if}
  233. </Name>
  234. {#if message.content === ''}
  235. <Skeleton />
  236. {:else}
  237. <div
  238. class="prose chat-{message.role} w-full max-w-full dark:prose-invert prose-headings:my-0 prose-p:my-0 prose-p:-mb-6 prose-pre:my-0 prose-table:my-0 prose-blockquote:my-0 prose-img:my-0 prose-ul:-my-4 prose-ol:-my-4 prose-li:-my-3 prose-ul:-mb-6 prose-ol:-mb-6 prose-li:-mb-4 whitespace-pre-line"
  239. >
  240. <div>
  241. {#if edit === true}
  242. <div class=" w-full">
  243. <textarea
  244. id="message-edit-{message.id}"
  245. class=" bg-transparent outline-none w-full resize-none"
  246. bind:value={editedContent}
  247. on:input={(e) => {
  248. e.target.style.height = `${e.target.scrollHeight}px`;
  249. }}
  250. />
  251. <div class=" mt-2 mb-1 flex justify-center space-x-2 text-sm font-medium">
  252. <button
  253. class="px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded-lg"
  254. on:click={() => {
  255. editMessageConfirmHandler();
  256. }}
  257. >
  258. Save
  259. </button>
  260. <button
  261. class=" px-4 py-2 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-100 transition outline outline-1 outline-gray-200 dark:outline-gray-600 rounded-lg"
  262. on:click={() => {
  263. cancelEditMessage();
  264. }}
  265. >
  266. Cancel
  267. </button>
  268. </div>
  269. </div>
  270. {:else}
  271. <div class="w-full">
  272. {#if message?.error === true}
  273. <div
  274. class="flex mt-2 mb-4 space-x-2 border px-4 py-3 border-red-800 bg-red-800/30 font-medium rounded-lg"
  275. >
  276. <svg
  277. xmlns="http://www.w3.org/2000/svg"
  278. fill="none"
  279. viewBox="0 0 24 24"
  280. stroke-width="1.5"
  281. stroke="currentColor"
  282. class="w-5 h-5 self-center"
  283. >
  284. <path
  285. stroke-linecap="round"
  286. stroke-linejoin="round"
  287. d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
  288. />
  289. </svg>
  290. <div class=" self-center">
  291. {message.content}
  292. </div>
  293. </div>
  294. {:else}
  295. {#each tokens as token}
  296. {#if token.type === 'code'}
  297. <!-- {token.text} -->
  298. <CodeBlock lang={token.lang} code={token.text} />
  299. {:else}
  300. {@html marked.parse(token.raw, {
  301. ...defaults,
  302. gfm: true,
  303. breaks: true,
  304. renderer
  305. })}
  306. {/if}
  307. {/each}
  308. <!-- {@html marked(message.content.replaceAll('\\', '\\\\'))} -->
  309. {/if}
  310. {#if message.done}
  311. <div
  312. class=" flex justify-start space-x-1 overflow-x-auto buttons text-gray-700 dark:text-gray-500"
  313. >
  314. {#if siblings.length > 1}
  315. <div class="flex self-center min-w-fit">
  316. <button
  317. class="self-center dark:hover:text-white hover:text-black transition"
  318. on:click={() => {
  319. showPreviousMessage(message);
  320. }}
  321. >
  322. <svg
  323. xmlns="http://www.w3.org/2000/svg"
  324. viewBox="0 0 20 20"
  325. fill="currentColor"
  326. class="w-4 h-4"
  327. >
  328. <path
  329. fill-rule="evenodd"
  330. d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z"
  331. clip-rule="evenodd"
  332. />
  333. </svg>
  334. </button>
  335. <div class="text-xs font-bold self-center min-w-fit dark:text-gray-100">
  336. {siblings.indexOf(message.id) + 1} / {siblings.length}
  337. </div>
  338. <button
  339. class="self-center dark:hover:text-white hover:text-black transition"
  340. on:click={() => {
  341. showNextMessage(message);
  342. }}
  343. >
  344. <svg
  345. xmlns="http://www.w3.org/2000/svg"
  346. viewBox="0 0 20 20"
  347. fill="currentColor"
  348. class="w-4 h-4"
  349. >
  350. <path
  351. fill-rule="evenodd"
  352. d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
  353. clip-rule="evenodd"
  354. />
  355. </svg>
  356. </button>
  357. </div>
  358. {/if}
  359. <button
  360. class="{isLastMessage
  361. ? 'visible'
  362. : 'invisible group-hover:visible'} p-1 rounded dark:hover:text-white hover:text-black transition"
  363. on:click={() => {
  364. editMessageHandler();
  365. }}
  366. >
  367. <svg
  368. xmlns="http://www.w3.org/2000/svg"
  369. fill="none"
  370. viewBox="0 0 24 24"
  371. stroke-width="1.5"
  372. stroke="currentColor"
  373. class="w-4 h-4"
  374. >
  375. <path
  376. stroke-linecap="round"
  377. stroke-linejoin="round"
  378. 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"
  379. />
  380. </svg>
  381. </button>
  382. <button
  383. class="{isLastMessage
  384. ? 'visible'
  385. : 'invisible group-hover:visible'} p-1 rounded dark:hover:text-white hover:text-black transition copy-response-button"
  386. on:click={() => {
  387. copyToClipboard(message.content);
  388. }}
  389. >
  390. <svg
  391. xmlns="http://www.w3.org/2000/svg"
  392. fill="none"
  393. viewBox="0 0 24 24"
  394. stroke-width="1.5"
  395. stroke="currentColor"
  396. class="w-4 h-4"
  397. >
  398. <path
  399. stroke-linecap="round"
  400. stroke-linejoin="round"
  401. 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"
  402. />
  403. </svg>
  404. </button>
  405. <button
  406. class="{isLastMessage
  407. ? 'visible'
  408. : 'invisible group-hover:visible'} p-1 rounded {message.rating === 1
  409. ? 'bg-gray-100 dark:bg-gray-800'
  410. : ''} dark:hover:text-white hover:text-black transition"
  411. on:click={() => {
  412. rateMessage(message.id, 1);
  413. }}
  414. >
  415. <svg
  416. stroke="currentColor"
  417. fill="none"
  418. stroke-width="2"
  419. viewBox="0 0 24 24"
  420. stroke-linecap="round"
  421. stroke-linejoin="round"
  422. class="w-4 h-4"
  423. xmlns="http://www.w3.org/2000/svg"
  424. ><path
  425. 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"
  426. /></svg
  427. >
  428. </button>
  429. <button
  430. class="{isLastMessage
  431. ? 'visible'
  432. : 'invisible group-hover:visible'} p-1 rounded {message.rating === -1
  433. ? 'bg-gray-100 dark:bg-gray-800'
  434. : ''} dark:hover:text-white hover:text-black transition"
  435. on:click={() => {
  436. rateMessage(message.id, -1);
  437. }}
  438. >
  439. <svg
  440. stroke="currentColor"
  441. fill="none"
  442. stroke-width="2"
  443. viewBox="0 0 24 24"
  444. stroke-linecap="round"
  445. stroke-linejoin="round"
  446. class="w-4 h-4"
  447. xmlns="http://www.w3.org/2000/svg"
  448. ><path
  449. 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"
  450. /></svg
  451. >
  452. </button>
  453. <button
  454. id="speak-button-{message.id}"
  455. class="{isLastMessage
  456. ? 'visible'
  457. : 'invisible group-hover:visible'} p-1 rounded dark:hover:text-white hover:text-black transition"
  458. on:click={() => {
  459. if (!loadingSpeech) {
  460. toggleSpeakMessage(message);
  461. }
  462. }}
  463. >
  464. {#if loadingSpeech}
  465. <svg
  466. class=" w-4 h-4"
  467. fill="currentColor"
  468. viewBox="0 0 24 24"
  469. xmlns="http://www.w3.org/2000/svg"
  470. ><style>
  471. .spinner_S1WN {
  472. animation: spinner_MGfb 0.8s linear infinite;
  473. animation-delay: -0.8s;
  474. }
  475. .spinner_Km9P {
  476. animation-delay: -0.65s;
  477. }
  478. .spinner_JApP {
  479. animation-delay: -0.5s;
  480. }
  481. @keyframes spinner_MGfb {
  482. 93.75%,
  483. 100% {
  484. opacity: 0.2;
  485. }
  486. }
  487. </style><circle class="spinner_S1WN" cx="4" cy="12" r="3" /><circle
  488. class="spinner_S1WN spinner_Km9P"
  489. cx="12"
  490. cy="12"
  491. r="3"
  492. /><circle class="spinner_S1WN spinner_JApP" cx="20" cy="12" r="3" /></svg
  493. >
  494. {:else if speaking}
  495. <svg
  496. xmlns="http://www.w3.org/2000/svg"
  497. fill="none"
  498. viewBox="0 0 24 24"
  499. stroke-width="1.5"
  500. stroke="currentColor"
  501. class="w-4 h-4"
  502. >
  503. <path
  504. stroke-linecap="round"
  505. stroke-linejoin="round"
  506. 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"
  507. />
  508. </svg>
  509. {:else}
  510. <svg
  511. xmlns="http://www.w3.org/2000/svg"
  512. fill="none"
  513. viewBox="0 0 24 24"
  514. stroke-width="1.5"
  515. stroke="currentColor"
  516. class="w-4 h-4"
  517. >
  518. <path
  519. stroke-linecap="round"
  520. stroke-linejoin="round"
  521. 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"
  522. />
  523. </svg>
  524. {/if}
  525. </button>
  526. {#if message.info}
  527. <button
  528. class=" {isLastMessage
  529. ? 'visible'
  530. : 'invisible group-hover:visible'} p-1 rounded dark:hover:text-white hover:text-black transition whitespace-pre-wrap"
  531. on:click={() => {
  532. console.log(message);
  533. }}
  534. id="info-{message.id}"
  535. >
  536. <svg
  537. xmlns="http://www.w3.org/2000/svg"
  538. fill="none"
  539. viewBox="0 0 24 24"
  540. stroke-width="1.5"
  541. stroke="currentColor"
  542. class="w-4 h-4"
  543. >
  544. <path
  545. stroke-linecap="round"
  546. stroke-linejoin="round"
  547. 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"
  548. />
  549. </svg>
  550. </button>
  551. {/if}
  552. {#if isLastMessage}
  553. <button
  554. type="button"
  555. class="{isLastMessage
  556. ? 'visible'
  557. : 'invisible group-hover:visible'} p-1 rounded dark:hover:text-white hover:text-black transition regenerate-response-button"
  558. on:click={() => {
  559. continueGeneration();
  560. }}
  561. >
  562. <svg
  563. xmlns="http://www.w3.org/2000/svg"
  564. fill="none"
  565. viewBox="0 0 24 24"
  566. stroke-width="1.5"
  567. stroke="currentColor"
  568. class="w-4 h-4"
  569. >
  570. <path
  571. stroke-linecap="round"
  572. stroke-linejoin="round"
  573. d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
  574. />
  575. <path
  576. stroke-linecap="round"
  577. stroke-linejoin="round"
  578. 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"
  579. />
  580. </svg>
  581. </button>
  582. <button
  583. type="button"
  584. class="{isLastMessage
  585. ? 'visible'
  586. : 'invisible group-hover:visible'} p-1 rounded dark:hover:text-white hover:text-black transition regenerate-response-button"
  587. on:click={regenerateResponse}
  588. >
  589. <svg
  590. xmlns="http://www.w3.org/2000/svg"
  591. fill="none"
  592. viewBox="0 0 24 24"
  593. stroke-width="1.5"
  594. stroke="currentColor"
  595. class="w-4 h-4"
  596. >
  597. <path
  598. stroke-linecap="round"
  599. stroke-linejoin="round"
  600. 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"
  601. />
  602. </svg>
  603. </button>
  604. {/if}
  605. </div>
  606. {/if}
  607. </div>
  608. {/if}
  609. </div>
  610. </div>
  611. {/if}
  612. </div>
  613. </div>
  614. {/key}
  615. <style>
  616. .buttons::-webkit-scrollbar {
  617. display: none; /* for Chrome, Safari and Opera */
  618. }
  619. .buttons {
  620. -ms-overflow-style: none; /* IE and Edge */
  621. scrollbar-width: none; /* Firefox */
  622. }
  623. </style>