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