-
Notifications
You must be signed in to change notification settings - Fork 0
Add the Koog Android example #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,3 +132,5 @@ dist | |
| .env | ||
| !.env.local.template | ||
| **/tsconfig.tsbuildinfo | ||
|
|
||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| *.iml | ||
| .kotlin | ||
| .gradle | ||
| **/build/ | ||
| xcuserdata | ||
| !src/**/build/ | ||
| local.properties | ||
| .idea | ||
| .DS_Store | ||
| captures | ||
| .externalNativeBuild | ||
| .cxx | ||
| *.xcodeproj/* | ||
| !*.xcodeproj/project.pbxproj | ||
| !*.xcodeproj/xcshareddata/ | ||
| !*.xcodeproj/project.xcworkspace/ | ||
| !*.xcworkspace/contents.xcworkspacedata | ||
| **/xcshareddata/WorkspaceSettings.xcsettings | ||
| node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # agent-koog | ||
|
|
||
| This is a Kotlin Multiplatform project targeting Android. | ||
|
|
||
| - [/composeApp](./composeApp/src) is for code that will be shared across your Compose Multiplatform applications. | ||
| It contains several subfolders: | ||
|
|
||
| - [commonMain](./composeApp/src/commonMain/kotlin) is for code that’s common for all targets. | ||
| - Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name. | ||
| For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app, | ||
| the [iosMain](./composeApp/src/iosMain/kotlin) folder would be the right place for such calls. | ||
| Similarly, if you want to edit the Desktop (JVM) specific part, the [jvmMain](./composeApp/src/jvmMain/kotlin) | ||
| folder is the appropriate location. | ||
|
|
||
| ## Build and Run Android Application | ||
|
|
||
| To build and run the development version of the Android app, use the run configuration from the run widget | ||
| in your IDE’s toolbar or build it directly from the terminal: | ||
|
|
||
| - on macOS/Linux | ||
|
|
||
| ```shell | ||
| ./gradlew :composeApp:assembleDebug | ||
| ``` | ||
|
|
||
| - on Windows | ||
|
|
||
| ```shell | ||
| .\gradlew.bat :composeApp:assembleDebug | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)… | ||
|
|
||
| ## Observability | ||
|
|
||
| `$download_url` は <https://www.jaegertracing.io/download/> からダウンロードURLを調べて取得したURLに置き換えてください。 | ||
|
|
||
| ```shell | ||
| # Jaegerを起動 | ||
| curl -sSL "$download_url" -o jaeger-2.13.0.tar.gz | ||
| tar -xzf jaeger-2.13.0.tar.gz | ||
| cd jaeger-2.13.0 | ||
| COLLECTOR_OTLP_ENABLED=true ./jaeger \ | ||
| --set=receivers.otlp.protocols.grpc.endpoint=0.0.0.0:4317 \ | ||
| --set=receivers.otlp.protocols.http.endpoint=0.0.0.0:4318 | ||
| ``` | ||
|
|
||
| Access to <http://localhost:16686/search> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| plugins { | ||
| // this is necessary to avoid the plugins to be loaded multiple times | ||
| // in each subproject's classloader | ||
| alias(libs.plugins.androidApplication) apply false | ||
| alias(libs.plugins.androidLibrary) apply false | ||
| alias(libs.plugins.composeMultiplatform) apply false | ||
| alias(libs.plugins.composeCompiler) apply false | ||
| alias(libs.plugins.kotlinMultiplatform) apply false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import org.jetbrains.compose.desktop.application.dsl.TargetFormat | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.kotlinMultiplatform) | ||
| alias(libs.plugins.androidApplication) | ||
| alias(libs.plugins.composeMultiplatform) | ||
| alias(libs.plugins.composeCompiler) | ||
|
|
||
| // Add Kotlin serialization plugin for Koog API support | ||
| kotlin("plugin.serialization") version "2.2.0" | ||
| } | ||
|
|
||
| kotlin { | ||
| androidTarget { | ||
| compilerOptions { | ||
| jvmTarget.set(JvmTarget.JVM_17) | ||
| } | ||
| } | ||
|
|
||
| sourceSets { | ||
| androidMain.dependencies { | ||
| implementation(compose.preview) | ||
| implementation(libs.androidx.activity.compose) | ||
| } | ||
| commonMain.dependencies { | ||
| implementation(compose.runtime) | ||
| implementation(compose.foundation) | ||
| implementation(compose.material3) | ||
| implementation(compose.ui) | ||
| implementation(libs.androidx.material.icons.core) | ||
| implementation(compose.components.resources) | ||
| implementation(compose.components.uiToolingPreview) | ||
| implementation(libs.androidx.lifecycle.viewmodelCompose) | ||
| implementation(libs.androidx.lifecycle.runtimeCompose) | ||
| implementation(libs.opentelemetry.logback.appender.x.x) | ||
| implementation(libs.slf4j.api) | ||
| implementation(libs.logback.android) | ||
| } | ||
| commonTest.dependencies { | ||
| implementation(libs.kotlin.test) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.example.koog_example" | ||
| compileSdk = libs.versions.android.compileSdk.get().toInt() | ||
|
|
||
| defaultConfig { | ||
| applicationId = "com.example.koog_example" | ||
| minSdk = libs.versions.android.minSdk.get().toInt() | ||
| targetSdk = libs.versions.android.targetSdk.get().toInt() | ||
| versionCode = 1 | ||
| versionName = "1.0" | ||
|
|
||
| // 環境変数から読み込んでBuildConfigに埋め込む | ||
| buildConfigField("String", "AWS_ACCESS_KEY_ID", "\"${System.getenv("AWS_ACCESS_KEY_ID") ?: ""}\"") | ||
| buildConfigField("String", "AWS_SECRET_ACCESS_KEY", "\"${System.getenv("AWS_SECRET_ACCESS_KEY") ?: ""}\"") | ||
| buildConfigField("String", "AWS_SESSION_TOKEN", "\"${System.getenv("AWS_SESSION_TOKEN") ?: ""}\"") | ||
| buildConfigField("String", "AWS_REGION", "\"${System.getenv("AWS_REGION") ?: "us-west-2"}\"") | ||
|
|
||
| buildConfigField("String", "OTLP_BACKEND", "\"${System.getenv("OTLP_BACKEND") ?: ""}\"") | ||
| buildConfigField("String", "OTLP_ENDPOINT", "\"${System.getenv("OTLP_ENDPOINT") ?: "http://10.0.2.2:4318/v1/traces"}\"") | ||
| buildConfigField("String", "OTLP_HEADERS", "\"${System.getenv("LANGFUSE_API_KEY") ?: ""}\"") | ||
| } | ||
| packaging { | ||
| resources { | ||
| excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
| } | ||
| dex { | ||
| useLegacyPackaging = false | ||
| } | ||
| } | ||
| buildTypes { | ||
| getByName("release") { | ||
| isMinifyEnabled = true | ||
| // 検証コードなのでproguard設定はしない | ||
| } | ||
| getByName("debug") { | ||
| applicationIdSuffix = ".debug" | ||
| isDebuggable = true | ||
| } | ||
|
poad marked this conversation as resolved.
|
||
| } | ||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 | ||
| } | ||
|
|
||
| buildFeatures { | ||
| buildConfig = true | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| debugImplementation(compose.uiTooling) | ||
| implementation(libs.koog.agents) | ||
| implementation(libs.opentelemetry.exporter.otlp) | ||
| implementation(libs.opentelemetry.exporter.logging) | ||
| } | ||
|
|
||
| repositories { | ||
| google() | ||
| // Use Maven Central for resolving dependencies. | ||
| mavenCentral() | ||
| // Add JetBrains repository for Koog framework | ||
| maven { | ||
| url = uri("https://packages.jetbrains.team/maven/p/grazi/grazie-platform-public") | ||
| } | ||
| } | ||
|
|
||
| configurations.all { | ||
| // FIXME exclude netty from Koog dependencies? | ||
| exclude(group = "io.netty", module = "*") | ||
| exclude(group = "org.apache.httpcomponents.httpclient5", module = "*") | ||
| exclude(group = "org.apache.httpcomponents.core5", module = "*") | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
agents/agent-koog/composeApp/src/androidMain/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <uses-permission android:name="android.permission.INTERNET" /> | ||
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
|
||
| <application | ||
| android:allowBackup="true" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="@string/app_name" | ||
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| android:theme="@android:style/Theme.Material.Light.NoActionBar" | ||
| android:networkSecurityConfig="@xml/network_security_config"> | ||
| <activity | ||
| android:exported="true" | ||
| android:name=".ChatActivity"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
|
|
||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
|
|
||
| </manifest> |
44 changes: 44 additions & 0 deletions
44
...agent-koog/composeApp/src/androidMain/composeResources/drawable/compose-multiplatform.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <vector | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:aapt="http://schemas.android.com/aapt" | ||
| android:width="450dp" | ||
| android:height="450dp" | ||
| android:viewportWidth="64" | ||
| android:viewportHeight="64"> | ||
| <path | ||
| android:pathData="M56.25,18V46L32,60 7.75,46V18L32,4Z" | ||
| android:fillColor="#6075f2"/> | ||
| <path | ||
| android:pathData="m41.5,26.5v11L32,43V60L56.25,46V18Z" | ||
| android:fillColor="#6b57ff"/> | ||
| <path | ||
| android:pathData="m32,43 l-9.5,-5.5v-11L7.75,18V46L32,60Z"> | ||
| <aapt:attr name="android:fillColor"> | ||
| <gradient | ||
| android:centerX="23.131" | ||
| android:centerY="18.441" | ||
| android:gradientRadius="42.132" | ||
| android:type="radial"> | ||
| <item android:offset="0" android:color="#FF5383EC"/> | ||
| <item android:offset="0.867" android:color="#FF7F52FF"/> | ||
| </gradient> | ||
| </aapt:attr> | ||
| </path> | ||
| <path | ||
| android:pathData="M22.5,26.5 L32,21 41.5,26.5 56.25,18 32,4 7.75,18Z"> | ||
| <aapt:attr name="android:fillColor"> | ||
| <gradient | ||
| android:startX="44.172" | ||
| android:startY="4.377" | ||
| android:endX="17.973" | ||
| android:endY="34.035" | ||
| android:type="linear"> | ||
| <item android:offset="0" android:color="#FF33C3FF"/> | ||
| <item android:offset="0.878" android:color="#FF5383EC"/> | ||
| </gradient> | ||
| </aapt:attr> | ||
| </path> | ||
| <path | ||
| android:pathData="m32,21 l9.526,5.5v11L32,43 22.474,37.5v-11z" | ||
| android:fillColor="#000000"/> | ||
| </vector> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.