Skip to content

Commit

Permalink
Merge pull request #9 from PatilShreyas/v0.5.0-wasm
Browse files Browse the repository at this point in the history
Sync wasm variant with v0.5.0
  • Loading branch information
PatilShreyas authored May 4, 2024
2 parents 4560a26 + c197baf commit 368b8b5
Show file tree
Hide file tree
Showing 105 changed files with 2,743 additions and 1,424 deletions.
1 change: 1 addition & 0 deletions .changes/generativeai/cork-dock-apple-cobweb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"PATCH","changes":["Remove usages of v1beta opt-in flag"]}
7 changes: 1 addition & 6 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ jobs:
- name: Publish Library
run: |
echo "Publishing library🚀"
./gradlew :generativeai:publish --no-configuration-cache
echo "Published Library✅"
echo "Releasing library...🚀"
./gradlew :generativeai:closeAndReleaseRepository --no-configuration-cache
echo "Released Library✅"
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_VERSION_NAME: ${{ github.event.inputs.versionName }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ generate text from text-and-image input:

```kotlin
val generativeModel = GenerativeModel(
modelName = "gemini-1.0-pro-vision-latest",
modelName = "gemini-1.5-pro-vision-latest",
apiKey = "YOUR_API_KEY"
)

Expand All @@ -33,7 +33,7 @@ Supports the following Kotlin Multiplatform targets:
- [x] iOS
- [x] JVM
- [x] JS
- [x] Wasm (_Use this [version](https://github.com/PatilShreyas/generative-ai-kmp/releases/tag/v0.2.0-1.0.0-wasm)_)
- [x] Wasm (_Use this [version](https://github.com/PatilShreyas/generative-ai-kmp/releases/tag/v0.5.0-1.0.0-wasm)_)

## Installation and usage

Expand All @@ -59,7 +59,7 @@ The versioning scheme is of the form `X-Y` where:

X is the _Generative AI Android SDK_ version that is being tracked.
Y is the _Multiplatform SDK_ version.
For example, if _Generative AI Android SDK_ is on `0.2.2` and _Multiplatform SDK_ is on `1.0.0`, the artifact for a release will be `dev.shreyaspatil.generativeai:generativeai-google:0.2.2-1.0.0`.
For example, if _Generative AI Android SDK_ is on `0.5.0` and _Multiplatform SDK_ is on `1.0.0`, the artifact for a release will be `dev.shreyaspatil.generativeai:generativeai-google:0.5.0-1.0.0`.

## Try sample app

Expand Down
319 changes: 0 additions & 319 deletions api/0.2.2.api

This file was deleted.

1 change: 1 addition & 0 deletions common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
129 changes: 129 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

/*
* Copyright 2024 Shreyas Patil
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
kotlin("plugin.serialization")
alias(libs.plugins.mavenPublish)
}

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
}
jvm()
js(IR) {
browser()
nodejs()
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "common"
isStatic = true
}
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "generativeAIGoogleCommon"
browser {
commonWebpackConfig {
outputFileName = "dev.shreyaspatil.generativeai-google-common.js"
}
}

binaries.executable()
}

sourceSets {
commonMain.dependencies {
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.client.serialization.json)
implementation(libs.ktor.client.logging)

implementation(libs.kotlinx.serialization.json)

implementation(libs.kotlinx.coroutines.core)
}
androidMain.dependencies {
api(libs.ktor.client.okhttp)
}
jvmMain.dependencies {
api(libs.ktor.client.okhttp)
api(libs.slf4j.api)
}
iosMain.dependencies {
api(libs.ktor.client.darwin)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
implementation(libs.kotest.assertions.core)
implementation(libs.kotest.assertions.json)
implementation(libs.ktor.client.mock)
}
}
}

android {
namespace = "dev.shreyaspatil.ai.client.generativeai.common"
compileSdk = 34

buildFeatures.buildConfig = true

defaultConfig {
minSdk = 21

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

testOptions {
unitTests.isReturnDefaultValues = true
}
}
21 changes: 21 additions & 0 deletions common/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions common/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
POM_ARTIFACT_ID=common
POM_NAME=Google Generative AI - Common
21 changes: 21 additions & 0 deletions common/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.shreyaspatil.ai.client.generativeai.platform
package dev.shreyaspatil.ai.client.generativeai.common.util

actual object Log {
actual fun d(tag: String, message: String) {
android.util.Log.d(tag, message)
}

actual fun w(tag: String, message: String) {
android.util.Log.w(tag, message)
}

actual fun e(tag: String, message: String) {
android.util.Log.e(tag, message)
actual fun e(tag: String, message: String, throwable: Throwable?) {
android.util.Log.e(tag, message, throwable)
}
}
Loading

0 comments on commit 368b8b5

Please sign in to comment.