Fix issues with token counts

This commit is contained in:
Webifi
2023-06-08 15:09:14 -05:00
parent 0cc30a28dc
commit 567845be06
4 changed files with 55 additions and 26 deletions

View File

@@ -8,6 +8,7 @@
import { errorNotice } from './Util.svelte'
export const chatsStorage = persisted('chats', [] as Chat[])
export const latestModelMap = persisted('latestModelMap', {} as Record<Model, Model>) // What was returned when a model was requested
export const globalStorage = persisted('global', {} as GlobalSettings)
export const apiKeyStorage = persisted('apiKey', '' as string)
export let checkStateChange = writable(0) // Trigger for Chat
@@ -462,5 +463,17 @@
}
return cname
}
export const getLatestKnownModel = (model:Model) => {
const modelMapStore = get(latestModelMap)
return modelMapStore[model] || model
}
export const setLatestKnownModel = (requestedModel:Model, responseModel:Model) => {
const modelMapStore = get(latestModelMap)
modelMapStore[requestedModel] = responseModel
latestModelMap.set(modelMapStore)
}
</script>