mirror of
https://github.com/jie65535/JChatGPT.git
synced 2025-07-28 18:59:20 +08:00
Add temperature config
This commit is contained in:
parent
7e1a1ad0aa
commit
7d911f2fb6
@ -314,19 +314,20 @@ object JChatGPT : KotlinPlugin(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val history = mutableListOf<ChatMessage>()
|
|
||||||
if (PluginConfig.prompt.isNotEmpty()) {
|
|
||||||
val prompt = getSystemPrompt(event)
|
|
||||||
if (PluginConfig.logPrompt) {
|
|
||||||
logger.info("Prompt: $prompt")
|
|
||||||
}
|
|
||||||
history.add(ChatMessage(ChatRole.System, prompt))
|
|
||||||
}
|
|
||||||
val historyText = getHistory(event)
|
|
||||||
logger.info("History: $historyText")
|
|
||||||
history.add(ChatMessage.User(historyText))
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val history = mutableListOf<ChatMessage>()
|
||||||
|
if (PluginConfig.prompt.isNotEmpty()) {
|
||||||
|
val prompt = getSystemPrompt(event)
|
||||||
|
if (PluginConfig.logPrompt) {
|
||||||
|
logger.info("Prompt: $prompt")
|
||||||
|
}
|
||||||
|
history.add(ChatMessage(ChatRole.System, prompt))
|
||||||
|
}
|
||||||
|
val historyText = getHistory(event)
|
||||||
|
logger.info("History: $historyText")
|
||||||
|
history.add(ChatMessage.User(historyText))
|
||||||
|
|
||||||
|
|
||||||
var done: Boolean
|
var done: Boolean
|
||||||
// 至少循环3次
|
// 至少循环3次
|
||||||
var retry = max(PluginConfig.retryMax, 3)
|
var retry = max(PluginConfig.retryMax, 3)
|
||||||
@ -387,13 +388,13 @@ object JChatGPT : KotlinPlugin(
|
|||||||
} else {
|
} else {
|
||||||
done = false
|
done = false
|
||||||
logger.warning("调用llm时发生异常,重试中", e)
|
logger.warning("调用llm时发生异常,重试中", e)
|
||||||
event.subject.sendMessage(event.message.quote() + "出错了...正在重试...")
|
event.subject.sendMessage("出错了...正在重试...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!done && 0 < --retry)
|
} while (!done && 0 < --retry)
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
logger.warning(ex)
|
logger.warning(ex)
|
||||||
event.subject.sendMessage(event.message.quote() + "很抱歉,发生异常,请稍后重试")
|
event.subject.sendMessage("很抱歉,发生异常,请稍后重试")
|
||||||
} finally {
|
} finally {
|
||||||
// 一段时间后才允许再次提问,防止高频对话
|
// 一段时间后才允许再次提问,防止高频对话
|
||||||
launch {
|
launch {
|
||||||
@ -728,7 +729,7 @@ object JChatGPT : KotlinPlugin(
|
|||||||
} else null
|
} else null
|
||||||
val request = ChatCompletionRequest(
|
val request = ChatCompletionRequest(
|
||||||
model = ModelId(PluginConfig.chatModel),
|
model = ModelId(PluginConfig.chatModel),
|
||||||
temperature = 1.3,
|
temperature = PluginConfig.chatTemperature,
|
||||||
messages = chatMessages,
|
messages = chatMessages,
|
||||||
tools = availableTools,
|
tools = availableTools,
|
||||||
)
|
)
|
||||||
|
@ -14,6 +14,9 @@ object PluginConfig : AutoSavePluginConfig("Config") {
|
|||||||
@ValueDescription("Chat模型")
|
@ValueDescription("Chat模型")
|
||||||
var chatModel: String by value("qwen-max")
|
var chatModel: String by value("qwen-max")
|
||||||
|
|
||||||
|
@ValueDescription("Chat模型温度,默认为null")
|
||||||
|
var chatTemperature: Double? by value(null)
|
||||||
|
|
||||||
@ValueDescription("推理模型API")
|
@ValueDescription("推理模型API")
|
||||||
var reasoningModelApi: String by value("https://dashscope.aliyuncs.com/compatible-mode/v1/")
|
var reasoningModelApi: String by value("https://dashscope.aliyuncs.com/compatible-mode/v1/")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user