-
Notifications
You must be signed in to change notification settings - Fork 0
Fix the KMP Support #151
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
Fix the KMP Support #151
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,72 @@ | ||
| # agent-koog | ||
|
|
||
| This is a Kotlin Multiplatform project targeting Android. | ||
| これは Android をターゲットとした Kotlin Multiplatform プロジェクトです。 | ||
| Kotlin Multiplatform による Amazon Bedrock を使った Koog によるチャットボットエージェントライブラリと、そのフロントエンドとなる Android アプリです。 | ||
|
|
||
| - [/composeApp](./composeApp/src) is for code that will be shared across your Compose Multiplatform applications. | ||
| It contains several subfolders: | ||
| - [/app](./app/src)は、フロントエンドとなる Android アプリです。 | ||
| - [/share](./share/src) は Compose Multiplatformアプリケーション間で共有されるコード用です。 | ||
|
|
||
| - [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 | ||
| サンプルアプリのため、AWSの一時的なクレデンシャルや OpenTelemetry Observer の設定はビルド時に環境変数から解決しています。 | ||
| Android Studio を使用する場合は、Android Studio の起動時に設定されている必要があります。 | ||
|
|
||
| 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: | ||
| | 環境変数名 | 必須か? | 設定する値の説明 | デフォルト値 | | ||
| | -------- | ---- | -------------- | ---------- | | ||
| | AWS_ACCESS_KEY_ID | 必須 | AWS のアクセスキーID (AWS IAM Identity Center の一時的なクレデンシャルの値で可) | (なし) | | ||
| | AWS_SECRET_ACCESS_KEY | 必須 | AWS のシークレットキー (AWS IAM Identity Center の一時的なクレデンシャルの値で可) | (なし) | | ||
| | AWS_SESSION_TOKEN | 条件次第 | AWS のセッショントークン (AWS IAM Identity Center の一時的なクレデンシャルの場合は必須) | (なし) | | ||
| | AWS_REGION | 任意 | AWS のリージョン | us-west-2 | | ||
| | OTLP_BACKEND | 条件次第 | 使用する Observer を指定。指定されない場合や不正値の場合は OpenTelemetry のトレーシングを送信しません。指定可能なObserver は現状、 jaeger または langfuse。※ langfuse は動作未確認 | (なし) | | ||
| | OTLP_ENDPOINT | 任意 | OpenTelemetry Observer のエンドポイント URL。OTLP_BACKEND に jaeger または langfuse が指定されている場合にのみ使われます。 | <http://10.0.2.2:4318/v1/traces> | | ||
| | OTLP_HEADERS | 任意 | Observer にテレメトリーを送信する際に付与する HTTP リクエストヘッダーを `ヘッダー名:値` 形式で指定できます。複数指定する場合は `,` 区切りとする想定ですが、現状は 1 つのみの指定しか対応していません。 | (なし) | | ||
|
|
||
| - on macOS/Linux | ||
| ### macOS で環境変数を設定して Android Studio を起動する方法 | ||
|
|
||
| ```shell | ||
| # (環境変数を export で設定) | ||
| export AWS_ACCESS_KEY_ID=XXXX | ||
| # (環境変数の設定の記述を割愛) | ||
|
|
||
| # Android Studio を起動 | ||
| open -a "Android Studio" | ||
| ``` | ||
|
|
||
| ## Androidアプリケーションのビルドと実行 | ||
|
|
||
| Androidアプリの開発バージョンをビルドして実行するには、IDEのツールバーにある実行ウィジェットから実行構成を使用するか、ターミナルから直接ビルドしてください: | ||
|
|
||
| - macOS/Linuxの場合 | ||
|
|
||
| ```shell | ||
| ./gradlew :composeApp:assembleDebug | ||
| ``` | ||
|
|
||
| - on Windows | ||
| - Windowsの場合 | ||
|
|
||
| ```shell | ||
| .\gradlew.bat :composeApp:assembleDebug | ||
| ``` | ||
|
|
||
| --- | ||
| [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)について詳しく学ぶ… | ||
|
|
||
| ## 可観測性(Observability) | ||
|
|
||
| Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)… | ||
| Langfuse などの SaaS を使用する前に、ローカルで Jaeger を使用して確認して、OpenTelemetry のトレースがきちんと登録できることを確認した上で SaaS を使うことで、アプリ側の計装や Android のネットワーク設定の問題か SaaS との連携固有の問題なのかを切り分けできます。 | ||
|
|
||
| ## Observability | ||
| ### Jaeger の起動方法 | ||
|
|
||
| `$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 | ||
| # Jaeger を起動 | ||
| curl -sSL "$download_url" -o jaeger.tar.gz | ||
| tar -xzf jaeger.tar.gz | ||
| cd jaeger | ||
| 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> | ||
| <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,81 @@ | ||
| plugins { | ||
| alias(libs.plugins.androidApplication) | ||
| alias(libs.plugins.kotlinAndroid) | ||
| alias(libs.plugins.composeCompiler) | ||
| alias(libs.plugins.composeMultiplatform) | ||
|
|
||
| // Add Kotlin serialization plugin for Koog API support | ||
| kotlin("plugin.serialization") version "2.3.0" | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.example.koog_example" | ||
| compileSdkVersion(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" | ||
| } | ||
|
|
||
| buildFeatures { | ||
| buildConfig = true | ||
| } | ||
|
|
||
| packaging { | ||
| resources { | ||
| excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
| } | ||
| dex { | ||
| useLegacyPackaging = false | ||
| } | ||
| } | ||
|
|
||
| buildTypes { | ||
| getByName("release") { | ||
| isMinifyEnabled = true | ||
| // 検証コードなのでproguard設定はしない | ||
| } | ||
| getByName("debug") { | ||
| applicationIdSuffix = ".debug" | ||
| isDebuggable = true | ||
| } | ||
| } | ||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_21 | ||
| targetCompatibility = JavaVersion.VERSION_21 | ||
| } | ||
|
|
||
| buildFeatures { | ||
| buildConfig = true | ||
| } | ||
|
poad marked this conversation as resolved.
|
||
| } | ||
|
|
||
| dependencies { | ||
| debugImplementation(compose.uiTooling) | ||
| // KMP 共有ライブラリへの依存 | ||
| implementation(project(":shared")) | ||
|
|
||
| implementation(compose.preview) | ||
| implementation(libs.androidx.activity.compose) | ||
| 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) | ||
| testImplementation(libs.kotlin.test) | ||
| androidTestImplementation(libs.androidx.espresso.core) | ||
| } | ||
|
|
||
| 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 = "*") | ||
| } | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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.