Remove linting diff

This commit is contained in:
Niek van der Maas 2023-03-20 15:58:14 +01:00
parent 0571a79886
commit 568c2d16ab
1 changed files with 14 additions and 48 deletions

View File

@ -1,12 +1,7 @@
<script lang="ts"> <script lang="ts">
// import { fetchEventSource } from "@microsoft/fetch-event-source"; // import { fetchEventSource } from "@microsoft/fetch-event-source";
import { import { apiKeyStorage, chatsStorage, addMessage, clearMessages } from './Storage.svelte'
apiKeyStorage,
chatsStorage,
addMessage,
clearMessages
} from './Storage.svelte'
import { import {
type Request, type Request,
type Response, type Response,
@ -183,14 +178,9 @@
// Provide the settings by mapping the settingsMap to key/value pairs // Provide the settings by mapping the settingsMap to key/value pairs
...settingsMap.reduce((acc, setting) => { ...settingsMap.reduce((acc, setting) => {
const value = ( const value = (settings.querySelector(`#settings-${setting.key}`) as HTMLInputElement).value
settings.querySelector(
`#settings-${setting.key}`
) as HTMLInputElement
).value
if (value) { if (value) {
acc[setting.key] = acc[setting.key] = setting.type === 'number' ? parseFloat(value) : value
setting.type === 'number' ? parseFloat(value) : value
} }
return acc return acc
}, {}) }, {})
@ -242,9 +232,7 @@
addMessage(chatId, choice.message) addMessage(chatId, choice.message)
// Use TTS to read the response, if query was recorded // Use TTS to read the response, if query was recorded
if (recorded && 'SpeechSynthesisUtterance' in window) { if (recorded && 'SpeechSynthesisUtterance' in window) {
const utterance = new SpeechSynthesisUtterance( const utterance = new SpeechSynthesisUtterance(choice.message.content)
choice.message.content
)
window.speechSynthesis.speak(utterance) window.speechSynthesis.speak(utterance)
} }
}) })
@ -278,9 +266,7 @@
const deleteChat = () => { const deleteChat = () => {
if (window.confirm('Are you sure you want to delete this chat?')) { if (window.confirm('Are you sure you want to delete this chat?')) {
replace('/').then(() => { replace('/').then(() => {
chatsStorage.update((chats) => chatsStorage.update((chats) => chats.filter((chat) => chat.id !== chatId))
chats.filter((chat) => chat.id !== chatId)
)
}) })
} }
} }
@ -328,9 +314,7 @@
const clearSettings = () => { const clearSettings = () => {
settingsMap.forEach((setting) => { settingsMap.forEach((setting) => {
const input = settings.querySelector( const input = settings.querySelector(`#settings-${setting.key}`) as HTMLInputElement
`#settings-${setting.key}`
) as HTMLInputElement
input.value = '' input.value = ''
}) })
} }
@ -397,9 +381,7 @@
{#if message.role === 'user'} {#if message.role === 'user'}
<article <article
class="message is-info user-message" class="message is-info user-message"
class:has-text-right={message.content class:has-text-right={message.content.split('\n').filter((line) => line.trim()).length === 1}
.split('\n')
.filter((line) => line.trim()).length === 1}
> >
<div class="message-body content"> <div class="message-body content">
<a <a
@ -445,13 +427,9 @@
/> />
{#if message.usage} {#if message.usage}
<p class="is-size-7"> <p class="is-size-7">
This message was generated using <span class="has-text-weight-bold" This message was generated using <span class="has-text-weight-bold">{message.usage.total_tokens}</span>
>{message.usage.total_tokens}</span
>
tokens ~= tokens ~=
<span class="has-text-weight-bold" <span class="has-text-weight-bold">${(message.usage.total_tokens * tokenPrice).toFixed(6)}</span>
>${(message.usage.total_tokens * tokenPrice).toFixed(6)}</span
>
</p> </p>
{/if} {/if}
</div> </div>
@ -463,10 +441,7 @@
<progress class="progress is-small is-dark" max="100" /> <progress class="progress is-small is-dark" max="100" />
{/if} {/if}
<form <form class="field has-addons has-addons-right" on:submit|preventDefault={() => submitForm()}>
class="field has-addons has-addons-right"
on:submit|preventDefault={() => submitForm()}
>
<p class="control is-expanded"> <p class="control is-expanded">
<textarea <textarea
class="input is-info is-focused chat-input" class="input is-info is-focused chat-input"
@ -488,17 +463,12 @@
/> />
</p> </p>
<p class="control" class:is-hidden={!recognition}> <p class="control" class:is-hidden={!recognition}>
<button <button class="button" class:is-pulse={recording} on:click|preventDefault={recordToggle}
class="button"
class:is-pulse={recording}
on:click|preventDefault={recordToggle}
><span class="greyscale">🎤</span></button ><span class="greyscale">🎤</span></button
> >
</p> </p>
<p class="control"> <p class="control">
<button class="button" on:click|preventDefault={showSettings} <button class="button" on:click|preventDefault={showSettings}><span class="greyscale">⚙️</span></button>
><span class="greyscale">⚙️</span></button
>
</p> </p>
<p class="control"> <p class="control">
<button class="button is-info" type="submit">Send</button> <button class="button is-info" type="submit">Send</button>
@ -524,9 +494,7 @@
{#each settingsMap as setting} {#each settingsMap as setting}
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="field-label is-normal"> <div class="field-label is-normal">
<label class="label" for="settings-{setting.key}" <label class="label" for="settings-{setting.key}">{setting.name}</label>
>{setting.name}</label
>
</div> </div>
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
@ -557,9 +525,7 @@
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">
<button class="button is-info" on:click={closeSettings} <button class="button is-info" on:click={closeSettings}>Close settings</button>
>Close settings</button
>
<button class="button" on:click={clearSettings}>Clear settings</button> <button class="button" on:click={clearSettings}>Clear settings</button>
</footer> </footer>
</div> </div>