Fix improper resetting of setting values
This commit is contained in:
parent
3dc30ad186
commit
9e2b354b0a
|
@ -22,7 +22,7 @@
|
||||||
} from './Types.svelte'
|
} from './Types.svelte'
|
||||||
import Prompts from './Prompts.svelte'
|
import Prompts from './Prompts.svelte'
|
||||||
import Messages from './Messages.svelte'
|
import Messages from './Messages.svelte'
|
||||||
import { applyProfile, getProfile, prepareSummaryPrompt } from './Profiles.svelte'
|
import { prepareSummaryPrompt, restartProfile } from './Profiles.svelte'
|
||||||
|
|
||||||
import { afterUpdate, onMount } from 'svelte'
|
import { afterUpdate, onMount } from 'svelte'
|
||||||
import Fa from 'svelte-fa/src/fa.svelte'
|
import Fa from 'svelte-fa/src/fa.svelte'
|
||||||
|
@ -64,8 +64,7 @@
|
||||||
clearTimeout(scDelay)
|
clearTimeout(scDelay)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (chat.startSession) {
|
if (chat.startSession) {
|
||||||
const profile = getProfile('') // get default profile
|
restartProfile(chatId)
|
||||||
applyProfile(chatId, profile.profile as any)
|
|
||||||
if (chat.startSession) {
|
if (chat.startSession) {
|
||||||
chat.startSession = false
|
chat.startSession = false
|
||||||
saveChatStore()
|
saveChatStore()
|
||||||
|
@ -120,8 +119,7 @@
|
||||||
console.log('Speech recognition not supported')
|
console.log('Speech recognition not supported')
|
||||||
}
|
}
|
||||||
if (chat.startSession) {
|
if (chat.startSession) {
|
||||||
const profile = getProfile('') // get default profile
|
restartProfile(chatId)
|
||||||
applyProfile(chatId, profile.profile as any)
|
|
||||||
if (chat.startSession) {
|
if (chat.startSession) {
|
||||||
chat.startSession = false
|
chat.startSession = false
|
||||||
saveChatStore()
|
saveChatStore()
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
} from '@fortawesome/free-solid-svg-icons/index'
|
} from '@fortawesome/free-solid-svg-icons/index'
|
||||||
import { apiKeyStorage, addChatFromJSON, chatsStorage, checkStateChange, clearChats, clearMessages, copyChat, globalStorage, setGlobalSettingValueByKey, showSetChatSettings, pinMainMenu } from './Storage.svelte'
|
import { apiKeyStorage, addChatFromJSON, chatsStorage, checkStateChange, clearChats, clearMessages, copyChat, globalStorage, setGlobalSettingValueByKey, showSetChatSettings, pinMainMenu } from './Storage.svelte'
|
||||||
import { exportAsMarkdown, exportChatAsJSON } from './Export.svelte'
|
import { exportAsMarkdown, exportChatAsJSON } from './Export.svelte'
|
||||||
import { applyProfile } from './Profiles.svelte'
|
import { restartProfile } from './Profiles.svelte'
|
||||||
import { replace } from 'svelte-spa-router'
|
import { replace } from 'svelte-spa-router'
|
||||||
import { clickOutside } from 'svelte-use-click-outside'
|
import { clickOutside } from 'svelte-use-click-outside'
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
const restartChatSession = () => {
|
const restartChatSession = () => {
|
||||||
close()
|
close()
|
||||||
applyProfile(chatId, '', true)
|
restartProfile(chatId)
|
||||||
$checkStateChange++ // signal chat page to start profile
|
$checkStateChange++ // signal chat page to start profile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,12 +71,10 @@ export const prepareSummaryPrompt = (chatId:number, promptsSize:number, maxToken
|
||||||
.replaceAll('[[MAX_WORDS]]', Math.floor(maxTokens * 0.75).toString()) // ~.75 words per token. May need to reduce
|
.replaceAll('[[MAX_WORDS]]', Math.floor(maxTokens * 0.75).toString()) // ~.75 words per token. May need to reduce
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply currently selected profile
|
// Restart currently loaded profile
|
||||||
export const applyProfile = (chatId:number, key:string = '', resetChat:boolean = false) => {
|
export const restartProfile = (chatId:number, noApply:boolean=false) => {
|
||||||
const settings = getChatSettings(chatId)
|
const settings = getChatSettings(chatId)
|
||||||
const profile = getProfile(key || settings.profile)
|
if (!settings.profile && !noApply) return applyProfile(chatId, '', true)
|
||||||
resetChatSettings(chatId, resetChat) // Fully reset
|
|
||||||
if (!resetChat) return
|
|
||||||
// Clear current messages
|
// Clear current messages
|
||||||
clearMessages(chatId)
|
clearMessages(chatId)
|
||||||
// Add the system prompt
|
// Add the system prompt
|
||||||
|
@ -88,8 +86,8 @@ export const applyProfile = (chatId:number, key:string = '', resetChat:boolean =
|
||||||
addMessage(chatId, systemPromptMessage)
|
addMessage(chatId, systemPromptMessage)
|
||||||
|
|
||||||
// Add trainingPrompts, if any
|
// Add trainingPrompts, if any
|
||||||
if (profile.trainingPrompts) {
|
if (settings.trainingPrompts) {
|
||||||
profile.trainingPrompts.forEach(tp => {
|
settings.trainingPrompts.forEach(tp => {
|
||||||
addMessage(chatId, tp)
|
addMessage(chatId, tp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -97,7 +95,16 @@ export const applyProfile = (chatId:number, key:string = '', resetChat:boolean =
|
||||||
getChat(chatId).startSession = settings.autoStartSession
|
getChat(chatId).startSession = settings.autoStartSession
|
||||||
saveChatStore()
|
saveChatStore()
|
||||||
// Mark mark this as last used
|
// Mark mark this as last used
|
||||||
setGlobalSettingValueByKey('lastProfile', key)
|
setGlobalSettingValueByKey('lastProfile', settings.profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply currently selected profile
|
||||||
|
export const applyProfile = (chatId:number, key:string = '', resetChat:boolean = false) => {
|
||||||
|
const settings = getChatSettings(chatId)
|
||||||
|
const profile = getProfile(key || settings.profile)
|
||||||
|
resetChatSettings(chatId, resetChat) // Fully reset
|
||||||
|
if (!resetChat) return
|
||||||
|
return restartProfile(chatId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const summaryPrompts = {
|
const summaryPrompts = {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import type { Chat, ChatSettings, GlobalSettings, Message, ChatSetting, GlobalSetting, Usage, Model } from './Types.svelte'
|
import type { Chat, ChatSettings, GlobalSettings, Message, ChatSetting, GlobalSetting, Usage, Model } from './Types.svelte'
|
||||||
import { getChatSettingObjectByKey, getGlobalSettingObjectByKey, getChatDefaults, getExcludeFromProfile } from './Settings.svelte'
|
import { getChatSettingObjectByKey, getGlobalSettingObjectByKey, getChatDefaults, getExcludeFromProfile } from './Settings.svelte'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { applyProfile, getProfile, isStaticProfile } from './Profiles.svelte'
|
import { getProfile, isStaticProfile, restartProfile } from './Profiles.svelte'
|
||||||
|
|
||||||
export const chatsStorage = persisted('chats', [] as Chat[])
|
export const chatsStorage = persisted('chats', [] as Chat[])
|
||||||
export const globalStorage = persisted('global', {} as GlobalSettings)
|
export const globalStorage = persisted('global', {} as GlobalSettings)
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
})
|
})
|
||||||
chatsStorage.set(chats)
|
chatsStorage.set(chats)
|
||||||
// Apply defaults and prepare it to start
|
// Apply defaults and prepare it to start
|
||||||
applyProfile(chatId, '', true)
|
restartProfile(chatId)
|
||||||
return chatId
|
return chatId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue