Don't show generation setting that don't apply

This commit is contained in:
Webifi 2023-07-22 08:56:12 -05:00
parent f538d23764
commit cdbd17fa13
2 changed files with 27 additions and 8 deletions

View File

@ -23,6 +23,14 @@
const chatId = chat.id const chatId = chat.id
let show = false let show = false
const valueOf = (value: any) => {
if (typeof value === 'function') return value(chatId, setting)
return value
}
let header = valueOf(setting.header)
let headerClass = valueOf(setting.headerClass)
const buildFieldControls = () => { const buildFieldControls = () => {
fieldControls = (setting.fieldControls || [] as FieldControl[]).map(fc => { fieldControls = (setting.fieldControls || [] as FieldControl[]).map(fc => {
return fc.getAction(chatId, setting, chatSettings[setting.key]) return fc.getAction(chatId, setting, chatSettings[setting.key])
@ -38,6 +46,8 @@
afterUpdate(() => { afterUpdate(() => {
show = (typeof setting.hide !== 'function') || !setting.hide(chatId) show = (typeof setting.hide !== 'function') || !setting.hide(chatId)
header = valueOf(setting.header)
headerClass = valueOf(setting.headerClass)
buildFieldControls() buildFieldControls()
}) })
@ -146,9 +156,9 @@
</script> </script>
{#if show} {#if show}
{#if setting.header} {#if header}
<p class="notification {setting.headerClass}"> <p class="notification {headerClass}">
{@html setting.header} {@html header}
</p> </p>
{/if} {/if}
<div class="field is-horizontal"> <div class="field is-horizontal">

View File

@ -17,7 +17,7 @@ import {
type ChatSortOption type ChatSortOption
} from './Types.svelte' } from './Types.svelte'
import { getTokens } from './Models.svelte' import { getModelDetail, getTokens } from './Models.svelte'
export const defaultModel:Model = 'gpt-3.5-turbo' export const defaultModel:Model = 'gpt-3.5-turbo'
@ -410,6 +410,10 @@ const modelSetting: ChatSetting & SettingSelect = {
afterChange: (chatId, setting) => true // refresh settings afterChange: (chatId, setting) => true // refresh settings
} }
const isNotOpenAI = (chatId) => {
return getModelDetail(getChatSettings(chatId).model).type !== 'OpenAIChat'
}
const chatSettingsList: ChatSetting[] = [ const chatSettingsList: ChatSetting[] = [
profileSetting, profileSetting,
...systemPromptSettings, ...systemPromptSettings,
@ -420,7 +424,8 @@ const chatSettingsList: ChatSetting[] = [
key: 'stream', key: 'stream',
name: 'Stream Response', name: 'Stream Response',
title: 'Stream responses as they are generated.', title: 'Stream responses as they are generated.',
type: 'boolean' type: 'boolean',
hide: isNotOpenAI
}, },
{ {
key: 'temperature', key: 'temperature',
@ -451,7 +456,8 @@ const chatSettingsList: ChatSetting[] = [
min: 1, min: 1,
max: 10, max: 10,
step: 1, step: 1,
type: 'number' type: 'number',
hide: isNotOpenAI
}, },
{ {
key: 'max_tokens', key: 'max_tokens',
@ -463,6 +469,7 @@ const chatSettingsList: ChatSetting[] = [
max: 32768, max: 32768,
step: 1, step: 1,
type: 'number', type: 'number',
hide: isNotOpenAI,
forceApi: true // Since default here is different than gpt default, will make sure we always send it forceApi: true // Since default here is different than gpt default, will make sure we always send it
}, },
{ {
@ -472,7 +479,8 @@ const chatSettingsList: ChatSetting[] = [
min: -2, min: -2,
max: 2, max: 2,
step: 0.2, step: 0.2,
type: 'number' type: 'number',
hide: isNotOpenAI
}, },
{ {
key: 'frequency_penalty', key: 'frequency_penalty',
@ -481,7 +489,8 @@ const chatSettingsList: ChatSetting[] = [
min: -2, min: -2,
max: 2, max: 2,
step: 0.2, step: 0.2,
type: 'number' type: 'number',
hide: isNotOpenAI
}, },
{ {
// logit bias editor not implemented yet // logit bias editor not implemented yet