Optimize search results

Add Weather Service Agent
Add Crazy Thursday Agent
This commit is contained in:
2024-12-21 13:58:02 +08:00
parent f91dbf8a6d
commit 98bcd3785b
6 changed files with 211 additions and 25 deletions

View File

@@ -1,14 +1,28 @@
package top.jie65535.mirai.tools
import com.aallam.openai.api.chat.Tool
import io.ktor.client.*
import io.ktor.client.engine.okhttp.*
import kotlinx.serialization.json.JsonObject
abstract class BaseAgent(
val tool: Tool
) {
/**
* 是否启用该工具
*/
open val isEnabled: Boolean = true
abstract suspend fun execute(args: JsonObject): String
/**
* 加载时消息 可用于提示用户正在执行
*/
open val loadingMessage: String = ""
protected val httpClient by lazy {
HttpClient(OkHttp)
}
abstract suspend fun execute(args: JsonObject?): String
override fun toString(): String {
return "${tool.function.name}: ${tool.function.description}"