Skip to content

Commit be98494

Browse files
authored
Merge pull request #173 from joreilly/junie
koog agent updates
2 parents eaf72ef + f64e70b commit be98494

File tree

5 files changed

+57
-20
lines changed

5 files changed

+57
-20
lines changed

.github/workflows/ios.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ jobs:
1818
distribution: 'zulu'
1919
java-version: 21
2020

21+
- name: Set Xcode Version 16.4
22+
shell: bash
23+
run: |
24+
xcodes select 16.4
25+
2126
- name: Build iOS app
2227
run: xcodebuild -allowProvisioningUpdates -allowProvisioningUpdates -workspace iosApp/iosApp.xcodeproj/project.xcworkspace -configuration Debug -scheme iosApp -sdk iphoneos -destination name='iPhone 16'
2328

.junie/guidelines.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Project Guidelines
2+
3+
## Project Structure
4+
This is a Kotlin Multiplatform project with Compose Multiplatform that includes:
5+
* `composeApp` - Shared Kotlin code with Compose UI
6+
* `iosApp` - iOS application
7+
8+
## Building the Project
9+
When building this project, Junie should use the following Gradle task:
10+
```
11+
:composeApp:compileKotlinJvm
12+
```

agents/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
dependencies {
66
implementation(libs.mcp.kotlin)
77
implementation(libs.koin.core)
8-
implementation("ai.koog:koog-agents:0.2.1")
8+
implementation("ai.koog:koog-agents:0.3.0")
99
//implementation("org.slf4j:slf4j-simple:2.0.17")
1010
implementation("com.google.adk:google-adk:0.2.0")
1111
implementation("com.google.adk:google-adk-dev:0.2.0")
Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,76 @@
11
package koog
22

33
import ai.koog.agents.core.agent.AIAgent
4-
import ai.koog.agents.core.tools.Tool
54
import ai.koog.agents.core.tools.ToolRegistry
65
import ai.koog.agents.core.tools.reflect.asTools
76
import ai.koog.agents.features.eventHandler.feature.handleEvents
87
import ai.koog.agents.mcp.McpToolRegistryProvider
98
import ai.koog.prompt.executor.clients.google.GoogleModels
109
import ai.koog.prompt.executor.clients.openai.OpenAIModels
1110
import ai.koog.prompt.executor.llms.all.simpleGoogleAIExecutor
11+
import ai.koog.prompt.executor.llms.all.simpleOllamaAIExecutor
1212
import ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor
13+
import ai.koog.prompt.llm.LLMCapability
14+
import ai.koog.prompt.llm.LLMProvider
15+
import ai.koog.prompt.llm.LLModel
1316
import kotlinx.coroutines.runBlocking
14-
import kotlin.uuid.ExperimentalUuidApi
15-
import kotlin.uuid.Uuid
1617

1718
val openAIApiKey = ""
1819
val apiKeyGoogle = ""
1920

2021

21-
@OptIn(ExperimentalUuidApi::class)
22+
2223
fun main() = runBlocking {
24+
25+
val model = LLModel(
26+
provider = LLMProvider.Ollama,
27+
id = "gpt-oss",
28+
//id = "llama3.1:8b",
29+
capabilities = listOf(
30+
LLMCapability.Temperature,
31+
LLMCapability.Schema.JSON.Simple,
32+
LLMCapability.Tools
33+
),
34+
)
35+
36+
2337
val agent = AIAgent(
2438
//executor = simpleOpenAIExecutor(openAIApiKey),
25-
executor = simpleGoogleAIExecutor(apiKeyGoogle),
39+
//executor = simpleGoogleAIExecutor(apiKeyGoogle),
40+
executor = simpleOllamaAIExecutor(),
2641
//llmModel = OpenAIModels.Chat.GPT4o,
27-
llmModel = GoogleModels.Gemini1_5Pro,
42+
//llmModel = GoogleModels.Gemini1_5Pro,
43+
llmModel = model,
2844
toolRegistry = createToolSetRegistry()
2945
) {
3046
handleEvents {
31-
onToolCall { tool: Tool<*, *>, toolArgs: Tool.Args ->
32-
println("Tool called: tool ${tool.name}, args $toolArgs")
47+
onToolCall { eventContext ->
48+
println("Tool called: ${eventContext.tool} with args ${eventContext.toolArgs}")
3349
}
34-
35-
onAgentRunError { strategyName: String, sessionUuid: Uuid?, throwable: Throwable ->
36-
println("An error occurred: ${throwable.message}\n${throwable.stackTraceToString()}")
50+
onAgentRunError { eventContext ->
51+
println("An error occurred: ${eventContext.throwable.message}\n${eventContext.throwable.stackTraceToString()}")
3752
}
38-
39-
onAgentFinished { strategyName, result ->
40-
println("Agent (strategy = $strategyName) finished with result: $result")
53+
onAgentFinished { eventContext ->
54+
println("Agent finished with result: ${eventContext.result}")
4155
}
4256
}
4357
}
4458

45-
agent.run(
59+
60+
val output = agent.run(
4661
"""
4762
Get emission data for France and Germany for 2023 and 2024.
48-
Use units of millions for the emissions data.
63+
Also break down by sector.
64+
Use 3 letter country codes.
65+
Use units of millions for the emissions data.
4966
""".trimIndent()
5067
)
68+
69+
println(output)
5170
}
5271

5372

73+
5474
suspend fun createToolSetRegistry(): ToolRegistry {
5575
val processClimateTrace = ProcessBuilder("java", "-jar",
5676
"./mcp-server/build/libs/serverAll.jar", "--stdio"
@@ -61,6 +81,6 @@ suspend fun createToolSetRegistry(): ToolRegistry {
6181
val localToolSetRegistry = ToolRegistry { tools(ClimateTraceTool().asTools()) }
6282

6383
// Can use either local toolset or one based on MCP server
64-
//return toolRegistryClimateTrace
65-
return localToolSetRegistry
84+
return toolRegistryClimateTrace
85+
//return localToolSetRegistry
6686
}

mcp-server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
dependencies {
1010
implementation(libs.mcp.kotlin)
1111
implementation(libs.koin.core)
12-
implementation("ch.qos.logback:logback-classic:1.5.8")
12+
//implementation("ch.qos.logback:logback-classic:1.5.8")
1313
implementation(projects.composeApp)
1414
}
1515

0 commit comments

Comments
 (0)