Move chat state values out of settings
This commit is contained in:
parent
bf00f23596
commit
c436fc6299
|
@ -124,12 +124,13 @@
|
||||||
} else {
|
} else {
|
||||||
console.log('Speech recognition not supported')
|
console.log('Speech recognition not supported')
|
||||||
}
|
}
|
||||||
if (chatSettings.startSession) {
|
if (chat.startSession) {
|
||||||
const profile = getProfile('') // get default profile
|
const profile = getProfile('') // get default profile
|
||||||
applyProfile(chatId, profile.profile as any)
|
applyProfile(chatId, profile.profile as any)
|
||||||
if (chatSettings.startSession) {
|
if (chat.startSession) {
|
||||||
setChatSettingValueByKey(chatId, 'startSession', false)
|
chat.startSession = false
|
||||||
// Auto start the session out of band
|
saveChatStore()
|
||||||
|
// Auto start the session
|
||||||
setTimeout(() => { submitForm(false, true) }, 0)
|
setTimeout(() => { submitForm(false, true) }, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +350,8 @@
|
||||||
if (updating) return
|
if (updating) return
|
||||||
|
|
||||||
if (!skipInput) {
|
if (!skipInput) {
|
||||||
setChatSettingValueByKey(chatId, 'sessionStarted', true)
|
chat.sessionStarted = true
|
||||||
|
saveChatStore()
|
||||||
if (input.value !== '') {
|
if (input.value !== '') {
|
||||||
// Compose the input message
|
// Compose the input message
|
||||||
const inputMessage: Message = { role: 'user', content: input.value, uuid: uuidv4() }
|
const inputMessage: Message = { role: 'user', content: input.value, uuid: uuidv4() }
|
||||||
|
@ -505,9 +507,10 @@
|
||||||
const closeSettings = () => {
|
const closeSettings = () => {
|
||||||
showSettingsModal = 0
|
showSettingsModal = 0
|
||||||
showProfileMenu = false
|
showProfileMenu = false
|
||||||
if (chat.settings.startSession) {
|
if (chat.startSession) {
|
||||||
setChatSettingValueByKey(chatId, 'startSession', false)
|
chat.startSession = false
|
||||||
submitForm(false, true)
|
saveChatStore()
|
||||||
|
submitForm(false, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +559,7 @@
|
||||||
window.alert('Unable to change:\n' + e.message)
|
window.alert('Unable to change:\n' + e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (setting.key === 'profile' && chatSettings.sessionStarted &&
|
if (setting.key === 'profile' && chat.sessionStarted &&
|
||||||
(getProfile(el.value).characterName !== chatSettings.characterName)) {
|
(getProfile(el.value).characterName !== chatSettings.characterName)) {
|
||||||
const val = chatSettings[setting.key]
|
const val = chatSettings[setting.key]
|
||||||
if (window.confirm('Personality change will not correctly apply to existing chat session.\n Continue?')) {
|
if (window.confirm('Personality change will not correctly apply to existing chat session.\n Continue?')) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script context="module" lang="ts">
|
<script context="module" lang="ts">
|
||||||
import { applyProfile } from './Profiles.svelte'
|
import { applyProfile } from './Profiles.svelte'
|
||||||
import { getChatSettings } from './Storage.svelte'
|
import { getChat, getChatSettings } from './Storage.svelte'
|
||||||
import { encode } from 'gpt-tokenizer'
|
import { encode } from 'gpt-tokenizer'
|
||||||
// Setting definitions
|
// Setting definitions
|
||||||
|
|
||||||
|
@ -79,10 +79,6 @@ const defaults:ChatSettings = {
|
||||||
systemPrompt: '',
|
systemPrompt: '',
|
||||||
autoStartSession: false,
|
autoStartSession: false,
|
||||||
trainingPrompts: [],
|
trainingPrompts: [],
|
||||||
// There are chat session state variables, and really don't belong here
|
|
||||||
// But it was easier to just put them here.
|
|
||||||
startSession: false, // Should the session start automatically
|
|
||||||
sessionStarted: false // Has the session started (user made a first request)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const excludeFromProfile = {
|
const excludeFromProfile = {
|
||||||
|
@ -101,7 +97,7 @@ const profileSetting: ChatSetting & SettingSelect = {
|
||||||
options: [], // Set by Profiles
|
options: [], // Set by Profiles
|
||||||
type: 'select',
|
type: 'select',
|
||||||
afterChange: (chatId, setting) => {
|
afterChange: (chatId, setting) => {
|
||||||
applyProfile(chatId, '', !getChatSettings(chatId).sessionStarted)
|
applyProfile(chatId, '', !getChat(chatId).sessionStarted)
|
||||||
return true // Signal we should refresh the setting modal
|
return true // Signal we should refresh the setting modal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,13 +156,6 @@ const nonRequestSettings: ChatSetting[] = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
hide: (chatId) => !getChatSettings(chatId).useSystemPrompt
|
hide: (chatId) => !getChatSettings(chatId).useSystemPrompt
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'startSession',
|
|
||||||
name: 'Auto-Start Trigger',
|
|
||||||
title: '',
|
|
||||||
type: 'boolean',
|
|
||||||
hide: (chatId) => true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'useSummarization',
|
key: 'useSummarization',
|
||||||
name: 'Enable Auto Summarize',
|
name: 'Enable Auto Summarize',
|
||||||
|
|
|
@ -30,7 +30,9 @@
|
||||||
name: `Chat ${chatId}`,
|
name: `Chat ${chatId}`,
|
||||||
settings: {} as ChatSettings,
|
settings: {} as ChatSettings,
|
||||||
messages: [],
|
messages: [],
|
||||||
usage: {} as Record<Model, Usage>
|
usage: {} as Record<Model, Usage>,
|
||||||
|
startSession: false,
|
||||||
|
sessionStarted: false,
|
||||||
})
|
})
|
||||||
chatsStorage.set(chats)
|
chatsStorage.set(chats)
|
||||||
// Apply defaults and prepare it to start
|
// Apply defaults and prepare it to start
|
||||||
|
@ -90,6 +92,8 @@
|
||||||
const usageMap:Record<Model, Usage> = {}
|
const usageMap:Record<Model, Usage> = {}
|
||||||
chat.usage = usageMap
|
chat.usage = usageMap
|
||||||
}
|
}
|
||||||
|
if (chat.startSession === undefined) chat.startSession = false
|
||||||
|
if (chat.sessionStarted === undefined) chat.sessionStarted = !!chat.messages.find(m => m.role === 'user')
|
||||||
chatsStorage.set(chats)
|
chatsStorage.set(chats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,6 @@
|
||||||
useSystemPrompt: boolean;
|
useSystemPrompt: boolean;
|
||||||
systemPrompt: string;
|
systemPrompt: string;
|
||||||
autoStartSession: boolean;
|
autoStartSession: boolean;
|
||||||
startSession: false;
|
|
||||||
sessionStarted: false;
|
|
||||||
trainingPrompts?: Message[];
|
trainingPrompts?: Message[];
|
||||||
} & Request;
|
} & Request;
|
||||||
|
|
||||||
|
@ -69,6 +67,8 @@
|
||||||
messages: Message[];
|
messages: Message[];
|
||||||
usage: Record<Model, Usage>;
|
usage: Record<Model, Usage>;
|
||||||
settings: ChatSettings;
|
settings: ChatSettings;
|
||||||
|
startSession: boolean;
|
||||||
|
sessionStarted: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ResponseOK = {
|
type ResponseOK = {
|
||||||
|
|
Loading…
Reference in New Issue