mirror of
https://github.com/jie65535/JChatGPT.git
synced 2025-06-02 17:39:10 +08:00
Update version to v1.2.1
Add system prompt replace local time
This commit is contained in:
parent
49b1b0c345
commit
5cef899993
@ -7,7 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "top.jie65535.mirai"
|
group = "top.jie65535.mirai"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -27,6 +27,7 @@ import net.mamoe.mirai.message.data.MessageSource.Key.quote
|
|||||||
import net.mamoe.mirai.message.sourceIds
|
import net.mamoe.mirai.message.sourceIds
|
||||||
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
|
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
|
||||||
import net.mamoe.mirai.utils.info
|
import net.mamoe.mirai.utils.info
|
||||||
|
import java.time.OffsetDateTime
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ object JChatGPT : KotlinPlugin(
|
|||||||
JvmPluginDescription(
|
JvmPluginDescription(
|
||||||
id = "top.jie65535.mirai.JChatGPT",
|
id = "top.jie65535.mirai.JChatGPT",
|
||||||
name = "J ChatGPT",
|
name = "J ChatGPT",
|
||||||
version = "1.2.0",
|
version = "1.2.1",
|
||||||
) {
|
) {
|
||||||
author("jie65535")
|
author("jie65535")
|
||||||
}
|
}
|
||||||
@ -125,12 +126,16 @@ object JChatGPT : KotlinPlugin(
|
|||||||
startChat(context)
|
startChat(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getSystemPrompt(): String {
|
||||||
|
return PluginConfig.prompt.replace("{time}", OffsetDateTime.now().toString())
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun MessageEvent.startChat(context: List<ChatMessage>? = null) {
|
private suspend fun MessageEvent.startChat(context: List<ChatMessage>? = null) {
|
||||||
val history = mutableListOf<ChatMessage>()
|
val history = mutableListOf<ChatMessage>()
|
||||||
if (!context.isNullOrEmpty()) {
|
if (!context.isNullOrEmpty()) {
|
||||||
history.addAll(context)
|
history.addAll(context)
|
||||||
} else if (PluginConfig.prompt.isNotEmpty()) {
|
} else if (PluginConfig.prompt.isNotEmpty()) {
|
||||||
history.add(ChatMessage(ChatRole.System, PluginConfig.prompt))
|
history.add(ChatMessage(ChatRole.System, getSystemPrompt()))
|
||||||
}
|
}
|
||||||
val msg = message.plainText()
|
val msg = message.plainText()
|
||||||
if (msg.isNotEmpty()) {
|
if (msg.isNotEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user