Giter Site home page Giter Site logo

narayan-dhingra / generative-ai-kmp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from patilshreyas/generative-ai-kmp

0.0 0.0 0.0 1.53 MB

✨Generative AI SDK for Kotlin Multiplatform (Supports: JVM, Android, iOS, Desktop, Web JS, Wasm)

License: Apache License 2.0

Kotlin 100.00%

generative-ai-kmp's Introduction

Google Generative AI SDK for Kotlin Multiplatform ✨

The Google Generative AI client SDK for Kotlin Multiplatform enables developers to use Google's state-of-the-art generative AI models (like Gemini) to build AI-powered features and applications. This SDK supports use cases like:

  • Generate text from text-only input
  • Generate text from text-and-images input (multimodal)
  • Build multi-turn conversations (chat)

For example, with just a few lines of code, you can access Gemini's multimodal capabilities to generate text from text-and-image input:

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

val cookieImageData: ByteArray = // ...
val inputContent = content {
  image(PlatformImage(cookieImageData))
  text("Does this look store-bought or homemade?")
}

val response = generativeModel.generateContent(inputContent)
print(response.text)

Supports the following Kotlin Multiplatform targets:

  • Android
  • iOS
  • JVM
  • JS
  • Wasm (Use this version)

Installation and usage

Add the following dependency to your Kotlin Multiplatform project for commonMain:

commonMain.dependencies {
    implementation("dev.shreyaspatil.generativeai:generativeai-google:<version>")
}

Check for latest version in the releases.

For detailed instructions, you can find a quickstart for the Google AI client SDK for Android (Since this is a Fork of the original project by Google).

This quickstart describes how to add your API key and the SDK's dependency to your app, initialize the model, and then call the API to access the model. It also describes some additional use cases and features, like streaming, counting tokens, and controlling responses.

Releases

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.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

Try these apps built with this SDK by the community:

  • PatilShreyas/ChaKt: Chat-prompt based app for Android, iOS, Desktop, Web. Powered by this multiplatform SDK.
  • joreilly/GeminiKMP: Kotlin Multiplatform sample that uses Gemini Generative AI APIs. Runs on Android, iOS, Desktop, WearOS and Wasm-based Compose for Web.

(Have you built anything on top of this SDK? Let's add it here)

Documentation

You can use the APIs mentioned in the API Reference by the official library.

From the official library, there are two major changes:

  • Package com.google is mapped to dev.shreyaspatil.
  • Image(Bitmap) was there for Android, instead PlatformImage(ByteArray) is used for KMP.

Contributing

See Contributing for more information on contributing to the client SDK for multiplatform.

Credits

Thanks to Google for the project: google/generative-ai-android.

Fork License

Copyright for portions of the code is held by [Google, 2023] as part of the project google/generative-ai-android under the Apache License, version 2.0. All other copyrights for project generative-ai-kmp are held by [Shreyas Patil, 2024] under the Apache License, Version 2.0.

License

The contents of this repository are licensed under the Apache License, version 2.0.

generative-ai-kmp's People

Contributors

patilshreyas avatar rlazo avatar davidmotson avatar daymxn avatar thatfiredev avatar emilypgoogle avatar ryanwilson avatar google-admin avatar 5peak2me avatar pedrosax avatar m-asadullah avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.