Add temperature config

This commit is contained in:
2025-07-17 12:45:08 +08:00
parent 7e1a1ad0aa
commit 7d911f2fb6
2 changed files with 19 additions and 15 deletions

View File

@ -314,6 +314,7 @@ object JChatGPT : KotlinPlugin(
return
}
try {
val history = mutableListOf<ChatMessage>()
if (PluginConfig.prompt.isNotEmpty()) {
val prompt = getSystemPrompt(event)
@ -326,7 +327,7 @@ object JChatGPT : KotlinPlugin(
logger.info("History: $historyText")
history.add(ChatMessage.User(historyText))
try {
var done: Boolean
// 至少循环3次
var retry = max(PluginConfig.retryMax, 3)
@ -387,13 +388,13 @@ object JChatGPT : KotlinPlugin(
} else {
done = false
logger.warning("调用llm时发生异常重试中", e)
event.subject.sendMessage(event.message.quote() + "出错了...正在重试...")
event.subject.sendMessage("出错了...正在重试...")
}
}
} while (!done && 0 < --retry)
} catch (ex: Throwable) {
logger.warning(ex)
event.subject.sendMessage(event.message.quote() + "很抱歉,发生异常,请稍后重试")
event.subject.sendMessage("很抱歉,发生异常,请稍后重试")
} finally {
// 一段时间后才允许再次提问,防止高频对话
launch {
@ -728,7 +729,7 @@ object JChatGPT : KotlinPlugin(
} else null
val request = ChatCompletionRequest(
model = ModelId(PluginConfig.chatModel),
temperature = 1.3,
temperature = PluginConfig.chatTemperature,
messages = chatMessages,
tools = availableTools,
)

View File

@ -14,6 +14,9 @@ object PluginConfig : AutoSavePluginConfig("Config") {
@ValueDescription("Chat模型")
var chatModel: String by value("qwen-max")
@ValueDescription("Chat模型温度默认为null")
var chatTemperature: Double? by value(null)
@ValueDescription("推理模型API")
var reasoningModelApi: String by value("https://dashscope.aliyuncs.com/compatible-mode/v1/")