This commit is contained in:
2025-08-08 11:21:10 +09:00
parent ec659c1ea5
commit b543b111ba
3 changed files with 36 additions and 46 deletions

View File

@@ -191,25 +191,24 @@ export class ChatRequest {
if (typeof setting.apiTransform === 'function') { if (typeof setting.apiTransform === 'function') {
value = setting.apiTransform(chatId, setting, value) value = setting.apiTransform(chatId, setting, value)
} }
console.log(key, value);
if (key === 'max_tokens') { if (key === 'max_tokens') {
if (opts.maxTokens) value = opts.maxTokens // only as large as requested if (opts.maxTokens) value = opts.maxTokens // only as large as requested
if (value > maxAllowed || value < 1) value = null // if over max model, do not define max if (value > maxAllowed || value < 1) value = null // if over max model, do not define max
if (value) value = Math.floor(value) if (value) value = Math.floor(value)
if (modelDetail.reasoning == true) { key = 'max_completion_tokens'
key = 'max_completion_tokens'
}
} }
if (key === 'n') { if (key === 'n') {
if (opts.streaming || opts.summaryRequest) { if (opts.streaming || opts.summaryRequest) {
/*
Streaming goes insane with more than one completion.
Doesn't seem like there's any way to separate the jumbled mess of deltas for the
different completions.
Summary should only have one completion
*/
value = 1 value = 1
} }
} }
if ( key === 'reasoning_effort') {
if (modelDetail.extparams != true) return acc
}
if ( key === 'verbosity') {
if (modelDetail.extparams != true) return acc
}
if (value !== null) acc[key] = value if (value !== null) acc[key] = value
return acc return acc
}, {}), }, {}),

View File

@@ -79,7 +79,8 @@ const gptDefaults = {
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0, frequency_penalty: 0,
logit_bias: null, logit_bias: null,
user: undefined reasoning_effort: null,
verbosity: null,
} }
// Core set of defaults // Core set of defaults
@@ -634,6 +635,28 @@ const chatSettingsList: ChatSetting[] = [
}, },
hide: hideModelSetting hide: hideModelSetting
}, },
{
key: 'reasoning_effort',
name: 'Reasoning Effort',
title: 'minimal, low, medium, high',
type: 'text',
placeholder: (chatId) => {
const val = getModelDetail(getChatSettings(chatId).model).systemEnd
return val || ''
},
hide: () => false
},
{
key: 'verbosity',
name: 'Verbosity',
title: 'low, medium, high',
type: 'text',
placeholder: (chatId) => {
const val = getModelDetail(getChatSettings(chatId).model).systemEnd
return val || ''
},
hide: () => false
},
{ {
key: 'leadPrompt', key: 'leadPrompt',
name: 'Completion Lead Sequence', name: 'Completion Lead Sequence',
@@ -645,38 +668,6 @@ const chatSettingsList: ChatSetting[] = [
}, },
hide: hideModelSetting hide: hideModelSetting
}, },
{
// logit bias editor not implemented yet
key: 'logit_bias',
name: 'Logit Bias',
title: 'Allows you to adjust bias of tokens used in completion.',
header: 'Logit Bias. See <a target="_blank" href="https://help.openai.com/en/articles/5247780-using-logit-bias-to-define-token-probability">this article</a> for more details.',
type: 'other',
hide: () => true,
// transform to word->weight pairs to token(s)->weight.
// -- care should be taken to have each word key in the each record formatted in a way where they
// only take one token each else you'll end up with results you probably don't want.
// Generally, leading space plus common lower case word will more often result in a single token
// See: https://platform.openai.com/tokenizer
apiTransform: (chatId, setting, val:Record<string, number>) => {
// console.log('logit_bias', val, getChatSettings(chatId).logit_bias)
if (!val) return null
const tokenized:Record<number, number> = Object.entries(val).reduce((a, [k, v]) => {
const tokens:number[] = getTokens(getChatSettings(chatId).model, k)
tokens.forEach(t => { a[t] = v })
return a
}, {} as Record<number, number>)
return tokenized
}
},
// Enable?
{
key: 'user',
name: 'User?',
title: 'Name of user?',
type: 'text',
hide: () => true
}
] ]
const chatSettingLookup:Record<string, ChatSetting> = chatSettingsList.reduce((a, v) => { const chatSettingLookup:Record<string, ChatSetting> = chatSettingsList.reduce((a, v) => {

View File

@@ -2,10 +2,10 @@
"claude-sonnet-4-20250514": { "prompt": 3.0, "completion": 15.0, "max": 200000 }, "claude-sonnet-4-20250514": { "prompt": 3.0, "completion": 15.0, "max": 200000 },
"claude-opus-4-20250514": { "prompt": 15.0, "completion": 75.0, "max": 200000 }, "claude-opus-4-20250514": { "prompt": 15.0, "completion": 75.0, "max": 200000 },
"claude-3-7-sonnet-20250219": { "prompt": 3.0, "completion": 15.0, "max": 200000 }, "claude-3-7-sonnet-20250219": { "prompt": 3.0, "completion": 15.0, "max": 200000 },
"gpt-5": { "prompt": 1.25, "completion": 10.0, "max": 131072 }, "gpt-5": { "prompt": 1.25, "completion": 10.0, "max": 200000, "reasoning": true },
"gpt-5-mini": { "prompt": 0.25, "completion": 2.00, "max": 131072 }, "gpt-5-mini": { "prompt": 0.25, "completion": 2.00, "max": 200000, "reasoning": true },
"gpt-5-nano": { "prompt": 0.05, "completion": 0.40, "max": 131072 }, "gpt-5-nano": { "prompt": 0.05, "completion": 0.40, "max": 200000, "reasoning": true },
"gpt-5-chat-latest": { "prompt": 1.25, "completion": 10.0, "max": 131072 }, "gpt-5-chat-latest": { "prompt": 1.25, "completion": 10.0, "max": 200000, "reasoning": true },
"gpt-4.1": { "prompt": 2.00, "completion": 8.00, "max": 131072 }, "gpt-4.1": { "prompt": 2.00, "completion": 8.00, "max": 131072 },
"gpt-4.1-mini": { "prompt": 0.40, "completion": 1.60, "max": 131072 }, "gpt-4.1-mini": { "prompt": 0.40, "completion": 1.60, "max": 131072 },
"gpt-4.1-nano": { "prompt": 0.10, "completion": 0.03, "max": 131072 }, "gpt-4.1-nano": { "prompt": 0.10, "completion": 0.03, "max": 131072 },