More linting
This commit is contained in:
parent
5fb12c1f41
commit
c5fd70df5f
|
@ -9,7 +9,8 @@
|
|||
type Settings,
|
||||
supportedModels,
|
||||
type ResponseModels,
|
||||
type SettingsSelect
|
||||
type SettingsSelect,
|
||||
type Chat
|
||||
} from './Types.svelte'
|
||||
import Code from './Code.svelte'
|
||||
|
||||
|
@ -17,7 +18,7 @@
|
|||
import { replace } from 'svelte-spa-router'
|
||||
import SvelteMarkdown from 'svelte-markdown'
|
||||
|
||||
export let params = { chatId: undefined }
|
||||
export let params = { chatId: '' }
|
||||
const chatId: number = parseInt(params.chatId)
|
||||
let updating: boolean = false
|
||||
|
||||
|
@ -90,7 +91,7 @@
|
|||
}
|
||||
]
|
||||
|
||||
$: chat = $chatsStorage.find((chat) => chat.id === chatId)
|
||||
$: chat = $chatsStorage.find((chat) => chat.id === chatId) as Chat
|
||||
const tokenPrice = 0.000002 // $0.002 per 1000 tokens
|
||||
|
||||
// Focus the input on mount
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
const clickedElement = event.target as HTMLButtonElement
|
||||
|
||||
// Get the next element
|
||||
const nextElement = clickedElement.nextElementSibling
|
||||
const nextElement = clickedElement.nextElementSibling as HTMLElement
|
||||
|
||||
// Modify the appearance of the button
|
||||
const originalButtonContent = clickedElement.innerHTML
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<script context="module" lang="ts">
|
||||
import { get } from 'svelte/store'
|
||||
import type { Chat } from './Types.svelte'
|
||||
import { chatsStorage } from './Storage.svelte'
|
||||
|
||||
export const exportAsMarkdown = (chatId: number) => {
|
||||
const chats = get(chatsStorage)
|
||||
const chat = chats.find((chat) => chat.id === chatId)
|
||||
const chat = chats.find((chat) => chat.id === chatId) as Chat
|
||||
const messages = chat.messages
|
||||
console.log(chat)
|
||||
let markdownContent = `# ${chat.name}\n`
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
<form
|
||||
class="field has-addons has-addons-right"
|
||||
on:submit|preventDefault={(event) => {
|
||||
if (event.target && event.target[0].value) {
|
||||
apiKeyStorage.set(event.target[0].value)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<p class="control is-expanded">
|
||||
|
|
|
@ -61,7 +61,9 @@
|
|||
class="panel-block"
|
||||
class:is-disabled={!apiKey}
|
||||
on:click|preventDefault={() => {
|
||||
exportAsMarkdown(activeChatId)
|
||||
if (activeChatId) {
|
||||
exportAsMarkdown(activeChatId)
|
||||
}
|
||||
}}><span class="greyscale mr-2">📥</span> Export chat</a
|
||||
>
|
||||
</li>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import type { Chat, Message } from './Types.svelte'
|
||||
|
||||
export const chatsStorage = persisted('chats', [] as Chat[])
|
||||
export const apiKeyStorage = persisted('apiKey', null as string)
|
||||
export const apiKeyStorage = persisted('apiKey', '' as string)
|
||||
|
||||
export const addChat = (): number => {
|
||||
const chats = get(chatsStorage)
|
||||
|
@ -28,14 +28,14 @@
|
|||
|
||||
export const addMessage = (chatId: number, message: Message) => {
|
||||
const chats = get(chatsStorage)
|
||||
const chat = chats.find((chat) => chat.id === chatId)
|
||||
const chat = chats.find((chat) => chat.id === chatId) as Chat
|
||||
chat.messages.push(message)
|
||||
chatsStorage.set(chats)
|
||||
}
|
||||
|
||||
export const editMessage = (chatId: number, index: number, newMessage: Message) => {
|
||||
const chats = get(chatsStorage)
|
||||
const chat = chats.find((chat) => chat.id === chatId)
|
||||
const chat = chats.find((chat) => chat.id === chatId) as Chat
|
||||
chat.messages[index] = newMessage
|
||||
chat.messages.splice(index + 1) // remove the rest of the messages
|
||||
chatsStorage.set(chats)
|
||||
|
@ -43,7 +43,7 @@
|
|||
|
||||
export const clearMessages = (chatId: number) => {
|
||||
const chats = get(chatsStorage)
|
||||
const chat = chats.find((chat) => chat.id === chatId)
|
||||
const chat = chats.find((chat) => chat.id === chatId) as Chat
|
||||
chat.messages = []
|
||||
chatsStorage.set(chats)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue