mirror of
https://github.com/jie65535/JChatGPT.git
synced 2025-10-20 17:13:37 +08:00
Update tool list
Disable EPIC Free game tool Fix the issue where invalid JSON parameters caused exceptions
This commit is contained in:
@@ -344,8 +344,7 @@ object JChatGPT : KotlinPlugin(
|
|||||||
val toolCallTasks = mutableListOf<Deferred<ChatMessage>>()
|
val toolCallTasks = mutableListOf<Deferred<ChatMessage>>()
|
||||||
// 处理聊天流式响应
|
// 处理聊天流式响应
|
||||||
responseFlow.collect { chunk ->
|
responseFlow.collect { chunk ->
|
||||||
val delta = chunk.choices[0].delta
|
val delta = chunk.choices[0].delta ?: return@collect
|
||||||
if (delta == null) return@collect
|
|
||||||
|
|
||||||
// 处理内容更新
|
// 处理内容更新
|
||||||
if (delta.content != null) {
|
if (delta.content != null) {
|
||||||
@@ -408,6 +407,7 @@ object JChatGPT : KotlinPlugin(
|
|||||||
|
|
||||||
// 移除思考内容
|
// 移除思考内容
|
||||||
val responseContent = responseMessageBuilder?.replace(thinkRegex, "")?.trim()
|
val responseContent = responseMessageBuilder?.replace(thinkRegex, "")?.trim()
|
||||||
|
logger.info("LLM Response: $responseContent")
|
||||||
// 记录AI回答
|
// 记录AI回答
|
||||||
history.add(ChatMessage.Assistant(
|
history.add(ChatMessage.Assistant(
|
||||||
content = responseContent,
|
content = responseContent,
|
||||||
@@ -440,11 +440,14 @@ object JChatGPT : KotlinPlugin(
|
|||||||
if (!done) {
|
if (!done) {
|
||||||
history.add(ChatMessage.User(
|
history.add(ChatMessage.User(
|
||||||
buildString {
|
buildString {
|
||||||
append("系统提示:本次运行还剩${retry-1}轮")
|
appendLine("系统提示:本次运行最多还剩${retry-1}轮。")
|
||||||
|
appendLine("如果要多次发言,可以一次性调用多次发言工具。")
|
||||||
|
appendLine("如果没有什么要做的,可以提前结束。")
|
||||||
|
appendLine("当前时间:" + dateTimeFormatter.format(OffsetDateTime.now()))
|
||||||
|
|
||||||
val newMessages = getAfterHistory(startedAt, event)
|
val newMessages = getAfterHistory(startedAt, event)
|
||||||
if (newMessages.isNotEmpty()) {
|
if (newMessages.isNotEmpty()) {
|
||||||
append("\n以下是上次运行至今的新消息\n\n$newMessages")
|
append("以下是上次运行至今的新消息\n\n$newMessages")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
@@ -535,12 +538,12 @@ object JChatGPT : KotlinPlugin(
|
|||||||
// 构造消息链
|
// 构造消息链
|
||||||
buildMessageChain {
|
buildMessageChain {
|
||||||
var index = 0
|
var index = 0
|
||||||
for ((range, msg) in t.sortedBy { it.range.start }) {
|
for ((range, msg) in t.sortedBy { it.range.first }) {
|
||||||
if (index < range.start) {
|
if (index < range.first) {
|
||||||
append(content, index, range.start)
|
append(content, index, range.first)
|
||||||
}
|
}
|
||||||
append(msg)
|
append(msg)
|
||||||
index = range.endInclusive + 1
|
index = range.last + 1
|
||||||
}
|
}
|
||||||
// 拼接后续消息
|
// 拼接后续消息
|
||||||
if (index < content.length) {
|
if (index < content.length) {
|
||||||
@@ -560,15 +563,15 @@ object JChatGPT : KotlinPlugin(
|
|||||||
// 发送组合消息
|
// 发送组合消息
|
||||||
SendCompositeMessage(),
|
SendCompositeMessage(),
|
||||||
|
|
||||||
|
// 结束循环
|
||||||
|
StopLoopAgent(),
|
||||||
|
|
||||||
// 记忆代理
|
// 记忆代理
|
||||||
MemoryAppend(),
|
MemoryAppend(),
|
||||||
|
|
||||||
// 记忆修改
|
// 记忆修改
|
||||||
MemoryReplace(),
|
MemoryReplace(),
|
||||||
|
|
||||||
// 结束循环
|
|
||||||
StopLoopAgent(),
|
|
||||||
|
|
||||||
// 网页搜索
|
// 网页搜索
|
||||||
WebSearch(),
|
WebSearch(),
|
||||||
|
|
||||||
@@ -584,11 +587,14 @@ object JChatGPT : KotlinPlugin(
|
|||||||
// 视觉代理
|
// 视觉代理
|
||||||
VisualAgent(),
|
VisualAgent(),
|
||||||
|
|
||||||
|
// 图像编辑模型
|
||||||
|
ImageEdit(),
|
||||||
|
|
||||||
// 天气服务
|
// 天气服务
|
||||||
WeatherService(),
|
WeatherService(),
|
||||||
|
|
||||||
// Epic 免费游戏
|
// Epic 免费游戏
|
||||||
EpicFreeGame(),
|
// EpicFreeGame(),
|
||||||
|
|
||||||
// 群管代理
|
// 群管代理
|
||||||
GroupManageAgent(),
|
GroupManageAgent(),
|
||||||
@@ -666,15 +672,15 @@ object JChatGPT : KotlinPlugin(
|
|||||||
val receipt = if (agent.loadingMessage.isNotEmpty()) {
|
val receipt = if (agent.loadingMessage.isNotEmpty()) {
|
||||||
event.subject.sendMessage(agent.loadingMessage)
|
event.subject.sendMessage(agent.loadingMessage)
|
||||||
} else null
|
} else null
|
||||||
// 提取参数
|
|
||||||
val args = function.argumentsAsJsonOrNull()
|
|
||||||
logger.info("Calling ${function.name}(${args})")
|
|
||||||
// 执行函数
|
// 执行函数
|
||||||
val result = try {
|
val result = try {
|
||||||
|
// 提取参数
|
||||||
|
val args = function.argumentsAsJsonOrNull()
|
||||||
|
logger.info("Calling ${function.name}(${args})")
|
||||||
agent.execute(args, event)
|
agent.execute(args, event)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
logger.error("Failed to call ${function.name}", e)
|
logger.error("Failed to call ${function.name}", e)
|
||||||
"工具调用失败,请尝试自行回答用户,或如实告知。"
|
"工具调用失败,请尝试自行回答用户,或如实告知。\n异常信息:${e.message}"
|
||||||
}
|
}
|
||||||
logger.info("Result=\"$result\"")
|
logger.info("Result=\"$result\"")
|
||||||
// 过会撤回加载消息
|
// 过会撤回加载消息
|
||||||
|
Reference in New Issue
Block a user