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

@ -22,6 +22,14 @@
const chatId = chat.id
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 = () => {
fieldControls = (setting.fieldControls || [] as FieldControl[]).map(fc => {
@ -38,6 +46,8 @@
afterUpdate(() => {
show = (typeof setting.hide !== 'function') || !setting.hide(chatId)
header = valueOf(setting.header)
headerClass = valueOf(setting.headerClass)
buildFieldControls()
})
@ -146,9 +156,9 @@
</script>
{#if show}
{#if setting.header}
<p class="notification {setting.headerClass}">
{@html setting.header}
{#if header}
<p class="notification {headerClass}">
{@html header}
</p>
{/if}
<div class="field is-horizontal">

View File

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