lint
This commit is contained in:
parent
5d7b51ba1d
commit
17d5ee196f
|
@ -62,7 +62,7 @@
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { exportChatAsJSON, exportProfileAsJSON } from './Export.svelte'
|
import { exportChatAsJSON, exportProfileAsJSON } from './Export.svelte'
|
||||||
import { clickOutside } from 'svelte-use-click-outside'
|
import { clickOutside } from 'svelte-use-click-outside'
|
||||||
import { getPrice } from './Stats.svelte';
|
import { getPrice } from './Stats.svelte'
|
||||||
|
|
||||||
// This makes it possible to override the OpenAI API base URL in the .env file
|
// This makes it possible to override the OpenAI API base URL in the .env file
|
||||||
const apiBase = import.meta.env.VITE_API_BASE || 'https://api.openai.com'
|
const apiBase = import.meta.env.VITE_API_BASE || 'https://api.openai.com'
|
||||||
|
@ -94,7 +94,6 @@
|
||||||
updateChatSettings(chatId)
|
updateChatSettings(chatId)
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
|
||||||
// Focus the input on mount
|
// Focus the input on mount
|
||||||
focusInput()
|
focusInput()
|
||||||
|
|
||||||
|
@ -782,7 +781,7 @@
|
||||||
</form>
|
</form>
|
||||||
<!-- a target to scroll to -->
|
<!-- a target to scroll to -->
|
||||||
<div class="chat-focus-point running-total-container">
|
<div class="chat-focus-point running-total-container">
|
||||||
{#each Object.entries(chat.usage||{}) as [model, usage]}
|
{#each Object.entries(chat.usage || {}) as [model, usage]}
|
||||||
<p class="is-size-7 running-totals">
|
<p class="is-size-7 running-totals">
|
||||||
<em>{model}</em> total <span class="has-text-weight-bold">{usage.total_tokens}</span>
|
<em>{model}</em> total <span class="has-text-weight-bold">{usage.total_tokens}</span>
|
||||||
tokens ~= <span class="has-text-weight-bold">${getPrice(usage, model).toFixed(6)}</span>
|
tokens ~= <span class="has-text-weight-bold">${getPrice(usage, model).toFixed(6)}</span>
|
||||||
|
|
|
@ -175,12 +175,6 @@
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
}
|
}
|
||||||
a.message-display {
|
|
||||||
display: block;
|
|
||||||
text-decoration: none !important;
|
|
||||||
min-width: 100px;
|
|
||||||
min-height: 30px;
|
|
||||||
}
|
|
||||||
.button-pack {
|
.button-pack {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
name: `Chat ${chatId}`,
|
name: `Chat ${chatId}`,
|
||||||
settings: {} as ChatSettings,
|
settings: {} as ChatSettings,
|
||||||
messages: [],
|
messages: [],
|
||||||
usage:{} as Record<Model,Usage>,
|
usage: {} as Record<Model, Usage>
|
||||||
})
|
})
|
||||||
chatsStorage.set(chats)
|
chatsStorage.set(chats)
|
||||||
// Apply defaults and prepare it to start
|
// Apply defaults and prepare it to start
|
||||||
|
@ -83,11 +83,11 @@
|
||||||
})
|
})
|
||||||
// Make sure the usage totals object is set
|
// Make sure the usage totals object is set
|
||||||
// (some earlier versions of this had different structures)
|
// (some earlier versions of this had different structures)
|
||||||
const hasUsage = chat.usage && !Array.isArray(chat.usage)
|
const hasUsage = chat.usage && !Array.isArray(chat.usage) &&
|
||||||
&& typeof chat.usage === 'object'
|
typeof chat.usage === 'object' &&
|
||||||
&& Object.values(chat.usage).find(v=>'prompt_tokens' in v)
|
Object.values(chat.usage).find(v => 'prompt_tokens' in v)
|
||||||
if (!hasUsage) {
|
if (!hasUsage) {
|
||||||
const usageMap:Record<Model,Usage> = {}
|
const usageMap:Record<Model, Usage> = {}
|
||||||
chat.usage = usageMap
|
chat.usage = usageMap
|
||||||
}
|
}
|
||||||
chatsStorage.set(chats)
|
chatsStorage.set(chats)
|
||||||
|
@ -138,8 +138,8 @@
|
||||||
total = {
|
total = {
|
||||||
prompt_tokens: 0,
|
prompt_tokens: 0,
|
||||||
completion_tokens: 0,
|
completion_tokens: 0,
|
||||||
total_tokens: 0,
|
total_tokens: 0
|
||||||
}
|
}
|
||||||
chat.usage[model] = total
|
chat.usage[model] = total
|
||||||
}
|
}
|
||||||
total.completion_tokens += usage.completion_tokens
|
total.completion_tokens += usage.completion_tokens
|
||||||
|
|
Loading…
Reference in New Issue