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"> <script lang="ts">
import { createEventDispatcher } from 'svelte' import { createEventDispatcher } from 'svelte'
import { getProfile } from "./lib/Profiles.svelte" import { getProfile } from './lib/Profiles.svelte'
import { setChatSettingValue } from "./lib/Storage.svelte" import { setChatSettingValue } from './lib/Storage.svelte'
import type { Chat, ChatSetting, ChatSettings } from "./lib/Types.svelte" import type { Chat, ChatSetting, ChatSettings } from './lib/Types.svelte'
import { autoGrowInputOnEvent } from "./lib/Util.svelte" import { autoGrowInputOnEvent } from './lib/Util.svelte'
export let setting:ChatSetting export let setting:ChatSetting
export let chatSettings:ChatSettings export let chatSettings:ChatSettings

View File

@ -179,7 +179,8 @@
const mlen = filtered.length - systemPad // always keep system prompt const mlen = filtered.length - systemPad // always keep system prompt
let diff = mlen - (pinTop + pinBottom) let diff = mlen - (pinTop + pinBottom)
const useRollMode = !prepareSummaryPrompt(chatId, 0) const useRollMode = !prepareSummaryPrompt(chatId, 0)
while (!useRollMode && diff <= 3 && (pinTop > 0 || pinBottom > 1)) { if (!useRollMode) {
while (diff <= 3 && (pinTop > 0 || pinBottom > 1)) {
// Not enough prompts exposed to summarize // Not enough prompts exposed to summarize
// try to open up pinTop and pinBottom to see if we can get more to summarize // try to open up pinTop and pinBottom to see if we can get more to summarize
if (pinTop === 1 && pinBottom > 1) { if (pinTop === 1 && pinBottom > 1) {
@ -191,6 +192,7 @@
} }
diff = mlen - (pinTop + pinBottom) diff = mlen - (pinTop + pinBottom)
} }
}
if (!useRollMode && diff > 0) { if (!useRollMode && diff > 0) {
// We've found at least one prompt we can try to summarize // We've found at least one prompt we can try to summarize
// Reduce to prompts we'll send in for summary // Reduce to prompts we'll send in for summary
@ -288,11 +290,11 @@
} else { } else {
// roll-off mode // roll-off mode
const top = filtered.slice(0, pinTop + systemPad) const top = filtered.slice(0, pinTop + systemPad)
let rollaway = filtered.slice(pinTop+systemPad) const rollaway = filtered.slice(pinTop + systemPad)
let promptTokenCount = countPromptTokens(top.concat(rollaway), model) let promptTokenCount = countPromptTokens(top.concat(rollaway), model)
// suppress messages we're rolling off // suppress messages we're rolling off
while (rollaway.length > (((promptTokenCount + (chatSettings.max_tokens||1)) > maxTokens) ? pinBottom||1 : 1) while (rollaway.length > (((promptTokenCount + (chatSettings.max_tokens || 1)) > maxTokens) ? pinBottom || 1 : 1) &&
&& promptTokenCount >= chatSettings.summaryThreshold) { promptTokenCount >= chatSettings.summaryThreshold) {
const rollOff = rollaway.shift() const rollOff = rollaway.shift()
if (rollOff) rollOff.suppress = true if (rollOff) rollOff.suppress = true
promptTokenCount = countPromptTokens(top.concat(rollaway), model) promptTokenCount = countPromptTokens(top.concat(rollaway), model)

View File

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

View File

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

View File

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