Start to add a way to show default profile
This commit is contained in:
parent
9b50517c38
commit
bf00f23596
|
@ -22,7 +22,7 @@
|
||||||
updateRunningTotal
|
updateRunningTotal
|
||||||
|
|
||||||
} from './Storage.svelte'
|
} from './Storage.svelte'
|
||||||
import { getChatSettingObjectByKey, getChatSettingList, getRequestSettingList } from './Settings.svelte'
|
import { getChatSettingObjectByKey, getChatSettingList, getRequestSettingList, getChatDefaults } from './Settings.svelte'
|
||||||
import {
|
import {
|
||||||
type Request,
|
type Request,
|
||||||
type Response,
|
type Response,
|
||||||
|
@ -36,7 +36,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, getProfileSelect, prepareSummaryPrompt } from './Profiles.svelte'
|
import { applyProfile, getProfile, getProfileSelect, prepareSummaryPrompt, getDefaultProfileKey } from './Profiles.svelte'
|
||||||
|
|
||||||
import { afterUpdate, onMount } from 'svelte'
|
import { afterUpdate, onMount } from 'svelte'
|
||||||
import { replace } from 'svelte-spa-router'
|
import { replace } from 'svelte-spa-router'
|
||||||
|
@ -85,6 +85,7 @@
|
||||||
|
|
||||||
const settingsList = getChatSettingList()
|
const settingsList = getChatSettingList()
|
||||||
const modelSetting = getChatSettingObjectByKey('model') as ChatSetting & SettingSelect
|
const modelSetting = getChatSettingObjectByKey('model') as ChatSetting & SettingSelect
|
||||||
|
const chatDefaults = getChatDefaults()
|
||||||
|
|
||||||
$: chat = $chatsStorage.find((chat) => chat.id === chatId) as Chat
|
$: chat = $chatsStorage.find((chat) => chat.id === chatId) as Chat
|
||||||
$: chatSettings = chat.settings
|
$: chatSettings = chat.settings
|
||||||
|
@ -447,6 +448,7 @@
|
||||||
const updateProfileSelectOptions = () => {
|
const updateProfileSelectOptions = () => {
|
||||||
const profileSelect = getChatSettingObjectByKey('profile') as ChatSetting & SettingSelect
|
const profileSelect = getChatSettingObjectByKey('profile') as ChatSetting & SettingSelect
|
||||||
profileSelect.options = getProfileSelect()
|
profileSelect.options = getProfileSelect()
|
||||||
|
chatDefaults.profile = getDefaultProfileKey()
|
||||||
// const defaultProfile = globalStore.defaultProfile || profileSelect.options[0].value
|
// const defaultProfile = globalStore.defaultProfile || profileSelect.options[0].value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +577,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const autoGrowInput = (el: HTMLTextAreaElement) => {
|
const autoGrowInput = (el: HTMLTextAreaElement) => {
|
||||||
el.style.height = '38px'; // don't use "auto" here. Firefox will over-size.
|
el.style.height = '38px' // don't use "auto" here. Firefox will over-size.
|
||||||
el.style.height = el.scrollHeight + 'px'
|
el.style.height = el.scrollHeight + 'px'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,8 +614,7 @@
|
||||||
saveCustomProfile(clone)
|
saveCustomProfile(clone)
|
||||||
chat.settings.profile = clone.profile
|
chat.settings.profile = clone.profile
|
||||||
chat.settings.profileName = clone.profileName
|
chat.settings.profileName = clone.profileName
|
||||||
updateProfileSelectOptions()
|
refreshSettings()
|
||||||
showSettingsModal && showSettingsModal++
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.alert('Error cloning profile: \n' + e.message)
|
window.alert('Error cloning profile: \n' + e.message)
|
||||||
}
|
}
|
||||||
|
@ -627,8 +628,7 @@
|
||||||
saveChatStore()
|
saveChatStore()
|
||||||
setGlobalSettingValueByKey('lastProfile', chat.settings.profile)
|
setGlobalSettingValueByKey('lastProfile', chat.settings.profile)
|
||||||
applyProfile(chatId, chat.settings.profile as any)
|
applyProfile(chatId, chat.settings.profile as any)
|
||||||
updateProfileSelectOptions()
|
refreshSettings()
|
||||||
showSettings()
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.alert('Error deleting profile: \n' + e.message)
|
window.alert('Error deleting profile: \n' + e.message)
|
||||||
}
|
}
|
||||||
|
@ -637,6 +637,7 @@
|
||||||
const pinDefaultProfile = () => {
|
const pinDefaultProfile = () => {
|
||||||
showProfileMenu = false
|
showProfileMenu = false
|
||||||
setGlobalSettingValueByKey('defaultProfile', chat.settings.profile)
|
setGlobalSettingValueByKey('defaultProfile', chat.settings.profile)
|
||||||
|
refreshSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
const importProfileFromFile = (e) => {
|
const importProfileFromFile = (e) => {
|
||||||
|
@ -650,8 +651,7 @@
|
||||||
profile.profileName = newNameForProfile(profile.profileName || '')
|
profile.profileName = newNameForProfile(profile.profileName || '')
|
||||||
profile.profile = null
|
profile.profile = null
|
||||||
saveCustomProfile(profile)
|
saveCustomProfile(profile)
|
||||||
updateProfileSelectOptions()
|
refreshSettings()
|
||||||
showSettingsModal && showSettingsModal++
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.alert('Unable to import profile: \n' + e.message)
|
window.alert('Unable to import profile: \n' + e.message)
|
||||||
}
|
}
|
||||||
|
@ -903,7 +903,7 @@
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select id="settings-{setting.key}" title="{setting.title}" on:change={e => queueSettingValueChange(e, setting) } >
|
<select id="settings-{setting.key}" title="{setting.title}" on:change={e => queueSettingValueChange(e, setting) } >
|
||||||
{#each setting.options as option}
|
{#each setting.options as option}
|
||||||
<option value={option.value} selected={option.value === chatSettings[setting.key]}>{option.text}</option>
|
<option class:is-default={option.value === chatDefaults[setting.key]} value={option.value} selected={option.value === chatSettings[setting.key]}>{option.text}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -974,13 +974,10 @@
|
||||||
.running-total-container {
|
.running-total-container {
|
||||||
min-height:2em;
|
min-height:2em;
|
||||||
padding-bottom:.6em;
|
padding-bottom:.6em;
|
||||||
padding-left: 1.9em;
|
/* padding-left: 1.9em; */
|
||||||
margin-bottom:-2.6em
|
margin-bottom:-2.6em
|
||||||
}
|
}
|
||||||
.running-totals {
|
.running-totals {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
.chat-input {
|
|
||||||
/* padding:0; */
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -33,6 +33,13 @@ export const getProfileSelect = ():SelectOption[] => {
|
||||||
}, [] as SelectOption[])
|
}, [] as SelectOption[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getDefaultProfileKey = ():string => {
|
||||||
|
const allProfiles = getProfiles()
|
||||||
|
return (allProfiles[getGlobalSettings().defaultProfile || ''] ||
|
||||||
|
profiles[defaultProfile] ||
|
||||||
|
profiles[Object.keys(profiles)[0]]).profile
|
||||||
|
}
|
||||||
|
|
||||||
export const getProfile = (key:string):ChatSettings => {
|
export const getProfile = (key:string):ChatSettings => {
|
||||||
const allProfiles = getProfiles()
|
const allProfiles = getProfiles()
|
||||||
const profile = allProfiles[key] ||
|
const profile = allProfiles[key] ||
|
||||||
|
|
|
@ -47,7 +47,7 @@ export const getExcludeFromProfile = () => {
|
||||||
return excludeFromProfile
|
return excludeFromProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
const gptDefaults: Request = Object.freeze({
|
const gptDefaults = {
|
||||||
model: 'gpt-3.5-turbo-0301',
|
model: 'gpt-3.5-turbo-0301',
|
||||||
messages: [],
|
messages: [],
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
|
@ -60,10 +60,10 @@ const gptDefaults: Request = Object.freeze({
|
||||||
frequency_penalty: 0,
|
frequency_penalty: 0,
|
||||||
logit_bias: null,
|
logit_bias: null,
|
||||||
user: undefined
|
user: undefined
|
||||||
})
|
}
|
||||||
|
|
||||||
// Core set of defaults
|
// Core set of defaults
|
||||||
const defaults:ChatSettings = Object.freeze({
|
const defaults:ChatSettings = {
|
||||||
...gptDefaults,
|
...gptDefaults,
|
||||||
profile: '',
|
profile: '',
|
||||||
characterName: 'ChatGPT',
|
characterName: 'ChatGPT',
|
||||||
|
@ -83,7 +83,7 @@ const defaults:ChatSettings = Object.freeze({
|
||||||
// But it was easier to just put them here.
|
// But it was easier to just put them here.
|
||||||
startSession: false, // Should the session start automatically
|
startSession: false, // Should the session start automatically
|
||||||
sessionStarted: false // Has the session started (user made a first request)
|
sessionStarted: false // Has the session started (user made a first request)
|
||||||
})
|
}
|
||||||
|
|
||||||
const excludeFromProfile = {
|
const excludeFromProfile = {
|
||||||
messages: true,
|
messages: true,
|
||||||
|
|
Loading…
Reference in New Issue