Skip to content

Commit f04d0ca

Browse files
xiaotianxtliby
authored andcommitted
feat: introduce temperature option
1 parent 8914ef0 commit f04d0ca

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/info.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@
167167
"value": ""
168168
}
169169
]
170+
},
171+
{
172+
"identifier": "temperature",
173+
"type": "text",
174+
"title": "温度",
175+
"defaultValue": "0.2",
176+
"desc": "可选项。温度值越高,生成的文本越随机。默认值为 0.2",
177+
"textConfig": {
178+
"type": "visible",
179+
"placeholderText": "0.2"
180+
}
170181
}
171182
]
172183
}

src/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function generatePrompts(query) {
7777
* }}
7878
*/
7979
function buildRequestBody(model, query) {
80-
let { customSystemPrompt, customUserPrompt } = $option;
80+
let { customSystemPrompt, customUserPrompt, temperature } = $option;
8181
const { generatedSystemPrompt, generatedUserPrompt } = generatePrompts(query);
8282

8383
customSystemPrompt = replacePromptKeywords(customSystemPrompt, query);
@@ -86,9 +86,11 @@ function buildRequestBody(model, query) {
8686
const systemPrompt = customSystemPrompt || generatedSystemPrompt;
8787
const userPrompt = customUserPrompt || generatedUserPrompt;
8888

89+
const modelTemperature = Number(temperature || 0.2);
90+
8991
const standardBody = {
9092
model: model,
91-
temperature: 0.2,
93+
temperature: modelTemperature,
9294
max_tokens: 1000,
9395
top_p: 1,
9496
frequency_penalty: 1,

0 commit comments

Comments
 (0)