This commit is contained in:
Webifi 2023-06-01 19:52:35 -05:00
parent 9165480dfb
commit 781d003849
5 changed files with 26 additions and 26 deletions

View File

@ -1,9 +1,9 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import { getProfile } from "./lib/Profiles.svelte"
import { setChatSettingValue } from "./lib/Storage.svelte"
import type { Chat, ChatSetting, ChatSettings } from "./lib/Types.svelte"
import { autoGrowInputOnEvent } from "./lib/Util.svelte"
import { getProfile } from './lib/Profiles.svelte'
import { setChatSettingValue } from './lib/Storage.svelte'
import type { Chat, ChatSetting, ChatSettings } from './lib/Types.svelte'
import { autoGrowInputOnEvent } from './lib/Util.svelte'
export let setting:ChatSetting
export let chatSettings:ChatSettings

View File

@ -179,17 +179,19 @@
const mlen = filtered.length - systemPad // always keep system prompt
let diff = mlen - (pinTop + pinBottom)
const useRollMode = !prepareSummaryPrompt(chatId, 0)
while (!useRollMode && diff <= 3 && (pinTop > 0 || pinBottom > 1)) {
// Not enough prompts exposed to summarize
// try to open up pinTop and pinBottom to see if we can get more to summarize
if (pinTop === 1 && pinBottom > 1) {
// If we have a pin top, try to keep some of it as long as we can
pinBottom = Math.max(Math.floor(pinBottom / 2), 0)
} else {
pinBottom = Math.max(Math.floor(pinBottom / 2), 0)
pinTop = Math.max(Math.floor(pinTop / 2), 0)
if (!useRollMode) {
while (diff <= 3 && (pinTop > 0 || pinBottom > 1)) {
// Not enough prompts exposed to summarize
// try to open up pinTop and pinBottom to see if we can get more to summarize
if (pinTop === 1 && pinBottom > 1) {
// If we have a pin top, try to keep some of it as long as we can
pinBottom = Math.max(Math.floor(pinBottom / 2), 0)
} else {
pinBottom = Math.max(Math.floor(pinBottom / 2), 0)
pinTop = Math.max(Math.floor(pinTop / 2), 0)
}
diff = mlen - (pinTop + pinBottom)
}
diff = mlen - (pinTop + pinBottom)
}
if (!useRollMode && diff > 0) {
// We've found at least one prompt we can try to summarize
@ -287,12 +289,12 @@
addMessage(chatId, { role: 'error', content: 'Unable to summarize. Not enough messages in past content to summarize.', uuid: uuidv4() })
} else {
// roll-off mode
const top = filtered.slice(0,pinTop+systemPad)
let rollaway = filtered.slice(pinTop+systemPad)
const top = filtered.slice(0, pinTop + systemPad)
const rollaway = filtered.slice(pinTop + systemPad)
let promptTokenCount = countPromptTokens(top.concat(rollaway), model)
// suppress messages we're rolling off
while (rollaway.length > (((promptTokenCount + (chatSettings.max_tokens||1)) > maxTokens) ? pinBottom||1 : 1)
&& promptTokenCount >= chatSettings.summaryThreshold) {
while (rollaway.length > (((promptTokenCount + (chatSettings.max_tokens || 1)) > maxTokens) ? pinBottom || 1 : 1) &&
promptTokenCount >= chatSettings.summaryThreshold) {
const rollOff = rollaway.shift()
if (rollOff) rollOff.suppress = true
promptTokenCount = countPromptTokens(top.concat(rollaway), model)

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { applyProfile, getDefaultProfileKey, getProfile, getProfileSelect } from './Profiles.svelte'
import { applyProfile, getDefaultProfileKey, getProfileSelect } from './Profiles.svelte'
import { getChatDefaults, getChatSettingList, getChatSettingObjectByKey } from './Settings.svelte'
import {
saveChatStore,
@ -10,11 +10,10 @@
deleteCustomProfile,
setGlobalSettingValueByKey,
resetChatSettings,
setChatSettingValue,
checkStateChange
} from './Storage.svelte'
import { supportedModels, type Chat, type ChatSetting, type ResponseModels, type SettingSelect, type SelectOption } from './Types.svelte'
import { sizeTextElements, autoGrowInputOnEvent } from './Util.svelte'
import { sizeTextElements } from './Util.svelte'
import Fa from 'svelte-fa/src/fa.svelte'
import {
faTrash,
@ -27,7 +26,7 @@
} from '@fortawesome/free-solid-svg-icons/index'
import { exportProfileAsJSON } from './Export.svelte'
import { afterUpdate } from 'svelte'
import ChatSettingField from '../ChatSettingField.svelte';
import ChatSettingField from '../ChatSettingField.svelte'
export let chatId:number
export const show = () => { showSettings() }

View File

@ -156,8 +156,7 @@
}
let waitingForSuppressConfirm:any = 0
const waitingForSuppressConfirm:any = 0
const setSuppress = (value:boolean) => {
// clearTimeout(waitingForSuppressConfirm); waitingForSuppressConfirm = 0

View File

@ -103,7 +103,7 @@ const profileSetting: ChatSetting & SettingSelect = {
},
setDefault: (chatId, setting, value) => {
},
}
}
// Settings that will not be part of the API request