Skip to content

Commit ed55fdf

Browse files
authored
feat: remove temperature/top_p settings as models now discourage them (#677)
Signed-off-by: Bob Du <i@bobdu.cc>
1 parent 8e69faf commit ed55fdf

15 files changed

Lines changed: 2 additions & 54 deletions

File tree

service/src/chatgpt/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async function chatReplyProcess(options: RequestOptions) {
122122
if (key == null || key === undefined)
123123
throw new Error('没有对应的apikeys配置。请再试一次 | No available apikeys configuration. Please try again.')
124124

125-
const { message, uploadFileKeys, parentMessageId, previousResponseId, tools, process, systemMessage, temperature, top_p, chatUuid } = options
125+
const { message, uploadFileKeys, parentMessageId, previousResponseId, tools, process, systemMessage, chatUuid } = options
126126
let instructions = systemMessage
127127

128128
try {
@@ -494,8 +494,6 @@ search result: <search_result>${searchResultContent}</search_result>`,
494494
const chatCompletionCreateBody: OpenAI.ChatCompletionCreateParamsStreaming = {
495495
model,
496496
messages: messages as OpenAI.Chat.ChatCompletionMessageParam[],
497-
temperature: temperature ?? undefined,
498-
top_p: top_p ?? undefined,
499497
stream: true,
500498
stream_options: {
501499
include_usage: true,

service/src/chatgpt/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ export interface RequestOptions {
4747
tools?: Array<ImageGenerationTool>
4848
process?: (chunk: ResponseChunk) => void
4949
systemMessage?: string
50-
temperature?: number
51-
top_p?: number
5250
user: UserInfo
5351
messageId: string
5452
room: ChatRoom

service/src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,6 @@ router.post('/setting-advanced', auth, async (req, res) => {
991991
try {
992992
const config = req.body as {
993993
systemMessage: string
994-
temperature: number
995-
top_p: number
996994
sync: boolean
997995
}
998996
if (config.sync) {
@@ -1003,17 +1001,13 @@ router.post('/setting-advanced', auth, async (req, res) => {
10031001
const thisConfig = await getOriginConfig()
10041002
thisConfig.advancedConfig = new AdvancedConfig(
10051003
config.systemMessage,
1006-
config.temperature,
1007-
config.top_p,
10081004
)
10091005
await updateConfig(thisConfig)
10101006
clearConfigCache()
10111007
}
10121008
const userId = req.headers.userId.toString()
10131009
await updateUserAdvancedConfig(userId, new AdvancedConfig(
10141010
config.systemMessage,
1015-
config.temperature,
1016-
config.top_p,
10171011
))
10181012
res.send({ status: 'Success', message: '操作成功 | Successfully' })
10191013
}

service/src/routes/chat.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
249249
res.setHeader('Access-Control-Allow-Origin', '*')
250250
res.setHeader('Access-Control-Allow-Headers', 'Cache-Control')
251251

252-
let { roomId, uuid, regenerate, prompt, uploadFileKeys, options = {}, systemMessage, temperature, top_p, tools, previousResponseId } = req.body as RequestProps
252+
let { roomId, uuid, regenerate, prompt, uploadFileKeys, options = {}, systemMessage, tools, previousResponseId } = req.body as RequestProps
253253
const userId = req.headers.userId.toString()
254254
const config = await getCacheConfig()
255255
const room = await getChatRoom(userId, roomId)
@@ -353,8 +353,6 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
353353
}
354354
},
355355
systemMessage,
356-
temperature,
357-
top_p,
358356
user,
359357
messageId: message._id.toString(),
360358
room,

service/src/storage/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export async function getOriginConfig() {
7777
if (!config.advancedConfig) {
7878
config.advancedConfig = new AdvancedConfig(
7979
'You are a large language model. Follow the user\'s instructions carefully. Respond using markdown (latex start with $).',
80-
0.8,
81-
1,
8280
)
8381
}
8482

service/src/storage/model.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ export class AuditConfig {
305305
export class AdvancedConfig {
306306
constructor(
307307
public systemMessage: string,
308-
public temperature: number,
309-
public top_p: number,
310308
) { }
311309
}
312310

service/src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export interface RequestProps {
1515
uploadFileKeys?: string[]
1616
options?: ChatContext
1717
systemMessage: string
18-
temperature?: number
19-
top_p?: number
2018
tools?: ImageGenerationTool[]
2119
previousResponseId?: string
2220
}

src/api/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export function fetchChatAPIProcessSSE(
5555
uploadFileKeys: params.uploadFileKeys,
5656
options: params.options,
5757
systemMessage: userStore.userInfo.advanced.systemMessage,
58-
temperature: userStore.userInfo.advanced.temperature,
59-
top_p: userStore.userInfo.advanced.top_p,
6058
}
6159

6260
if (params.tools && params.tools.length > 0) {

src/components/common/Setting/Advanced.vue

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ function handleReset() {
2828
<NInput v-model:value="userStore.userInfo.advanced.systemMessage" type="textarea" :autosize="{ minRows: 1, maxRows: 4 }" />
2929
</div>
3030
</div>
31-
<div class="flex items-center space-x-4">
32-
<span class="shrink-0 w-[120px]">{{ t('setting.temperature') }} </span>
33-
<div class="flex-1">
34-
<NSlider v-model:value="userStore.userInfo.advanced.temperature" :max="1" :min="0" :step="0.1" />
35-
</div>
36-
<span>{{ userStore.userInfo.advanced.temperature }}</span>
37-
</div>
38-
<div class="flex items-center space-x-4">
39-
<span class="shrink-0 w-[120px]">{{ t('setting.top_p') }} </span>
40-
<div class="flex-1">
41-
<NSlider v-model:value="userStore.userInfo.advanced.top_p" :max="1" :min="0" :step="0.1" />
42-
</div>
43-
<span>{{ userStore.userInfo.advanced.top_p }}</span>
44-
</div>
4531
<div class="flex items-center space-x-4">
4632
<span class="shrink-0 w-[120px]">&nbsp;</span>
4733
<NButton type="primary" @click="updateSettings(false)">

src/locales/en-US.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@
144144
"avatarLink": "Avatar Link",
145145
"name": "Name",
146146
"description": "Description",
147-
"temperature": "Temperature",
148-
"top_p": "Top_p",
149147
"saveUserInfo": "Save User Info",
150148
"role": "Role",
151149
"chatHistory": "ChatHistory",

0 commit comments

Comments
 (0)