调整旧代码
This commit is contained in:
@@ -5,12 +5,11 @@ val logback_version: String by project
|
|||||||
val kotlinx_html_version: String by project
|
val kotlinx_html_version: String by project
|
||||||
val ktor_version: String by project
|
val ktor_version: String by project
|
||||||
val exposed_version: String by project
|
val exposed_version: String by project
|
||||||
val h2_version: String by project
|
|
||||||
val postgres_version: String by project
|
val postgres_version: String by project
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.1.0"
|
kotlin("jvm") version "2.1.0"
|
||||||
id("io.ktor.plugin") version "3.1.3"
|
id("io.ktor.plugin") version "3.2.3"
|
||||||
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.20"
|
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,4 +102,6 @@ dependencies {
|
|||||||
implementation("io.ktor:ktor-client-serialization:$ktor_version")
|
implementation("io.ktor:ktor-client-serialization:$ktor_version")
|
||||||
// 数据库迁移
|
// 数据库迁移
|
||||||
// implementation("org.flywaydb:flyway-core:10.13.0")
|
// implementation("org.flywaydb:flyway-core:10.13.0")
|
||||||
|
|
||||||
|
implementation("ai.koog:koog-agents:0.3.0")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
ktor_version=3.0.2
|
ktor_version=3.2.3
|
||||||
kotlin_version=2.1.0
|
kotlin_version=2.1.0
|
||||||
logback_version=1.4.14
|
logback_version=1.4.14
|
||||||
kotlinx_html_version=0.10.1
|
kotlinx_html_version=0.10.1
|
||||||
exposed_version=1.0.0-beta-2
|
exposed_version=1.0.0-beta-2
|
||||||
h2_version=2.1.214
|
|
||||||
postgres_version=42.7.4
|
postgres_version=42.7.4
|
||||||
@@ -5,6 +5,7 @@ import ink.snowflake.server.plugins.*
|
|||||||
import ink.snowflake.server.route.User
|
import ink.snowflake.server.route.User
|
||||||
import ink.snowflake.server.route.chat
|
import ink.snowflake.server.route.chat
|
||||||
import ink.snowflake.server.plugins.configureSockets
|
import ink.snowflake.server.plugins.configureSockets
|
||||||
|
import ink.snowflake.server.route.AI
|
||||||
import ink.snowflake.server.route.ImageAnalytics
|
import ink.snowflake.server.route.ImageAnalytics
|
||||||
import ink.snowflake.server.route.RemoteDebug
|
import ink.snowflake.server.route.RemoteDebug
|
||||||
import ink.snowflake.server.route.VideoAnalytics
|
import ink.snowflake.server.route.VideoAnalytics
|
||||||
@@ -65,4 +66,6 @@ fun Application.module() {
|
|||||||
VideoAnalyticsJetson()
|
VideoAnalyticsJetson()
|
||||||
// 业务-图片分析
|
// 业务-图片分析
|
||||||
ImageAnalytics()
|
ImageAnalytics()
|
||||||
|
// 业务-AI
|
||||||
|
AI()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package ink.snowflake.server.route
|
||||||
|
|
||||||
|
import ai.koog.agents.core.agent.AIAgent
|
||||||
|
import ai.koog.agents.core.tools.ToolRegistry
|
||||||
|
import ai.koog.agents.ext.tool.SayToUser
|
||||||
|
import ai.koog.prompt.executor.clients.openai.OpenAIModels
|
||||||
|
import ai.koog.prompt.executor.llms.all.simpleOllamaAIExecutor
|
||||||
|
import ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor
|
||||||
|
import ai.koog.prompt.executor.ollama.client.OllamaClient
|
||||||
|
import ai.koog.prompt.executor.ollama.client.OllamaModelCard
|
||||||
|
import ai.koog.prompt.llm.LLMCapability
|
||||||
|
import ai.koog.prompt.llm.LLMProvider
|
||||||
|
import ai.koog.prompt.llm.LLModel
|
||||||
|
import ink.snowflake.server.model.response.BaseResponse
|
||||||
|
import io.ktor.server.application.Application
|
||||||
|
import io.ktor.server.response.respond
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
import io.ktor.server.routing.routing
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
fun Application.AI() {
|
||||||
|
|
||||||
|
val agent = AIAgent(
|
||||||
|
executor = simpleOllamaAIExecutor("http://171.212.101.199:13011/"),
|
||||||
|
systemPrompt = "You are a helpful assistant. Answer user questions concisely.", //系统提示词
|
||||||
|
llmModel = LLModel(
|
||||||
|
provider = LLMProvider.Ollama,
|
||||||
|
id = "llama3.2:latest",
|
||||||
|
capabilities = listOf(
|
||||||
|
LLMCapability.Temperature,
|
||||||
|
// LLMCapability.Tools
|
||||||
|
)
|
||||||
|
), // 模型
|
||||||
|
temperature = 0.7, // 温度
|
||||||
|
// toolRegistry = ToolRegistry {
|
||||||
|
// tool(SayToUser) // 注册工具
|
||||||
|
// },
|
||||||
|
maxIterations = 30 //
|
||||||
|
)
|
||||||
|
|
||||||
|
routing {
|
||||||
|
route("/api") {
|
||||||
|
get("/getAiList") {
|
||||||
|
val result = agent.run("Hello! How can you help me?")
|
||||||
|
call.respond(BaseResponse(data = result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user