Giter Site home page Giter Site logo

patilshreyas / generative-ai-kmp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google-gemini/generative-ai-android

93.0 3.0 7.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%
android desktop gemini generative-ai ios javascript js kmp kotlin kotlin-library kotlin-multiplatform web

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

Stargazers

Kris Bitney avatar Hoang Nguyen avatar CyberKid avatar Muhammad Irsyad Yunus avatar Ivanov Kirill A. avatar Diego Beraldin avatar ILYAS KERBAL avatar umesh gupta avatar   ahmed  avatar Kaloyan Karaivanov avatar Mohammad Anwar avatar André Mion avatar Alishan Ladhani avatar Blaž Šolar avatar Seiko avatar STUDIOSROGER  avatar Snehangshu Bhattacharya avatar Giridhara Sai Pavan Kumar Gurram avatar Shabinder Singh avatar  avatar Pushpal Roy avatar xiaobailong24 avatar Gregory Romanowski avatar Sunil Kumar avatar Josue Lubaki avatar Alper KILIÇER avatar Yingru Shih(Luna) avatar  avatar Karthi Keyan avatar itshan avatar Mike Odnis avatar  avatar Jerry Zhao avatar  avatar Karthik Kompelli avatar Joel Handwell avatar jherrero avatar Jose Jordan avatar Sasikanth avatar Csaba Huszar avatar Chayaphon Pansuwan avatar sonu pandey avatar Randhir Kumar Gupta avatar jamilxt avatar Solomon Njogo avatar Chetan Gupta avatar  avatar Swapnil Musale avatar Muhammad Sayed avatar Binay Shaw avatar Aritra Das avatar Vishal Singh avatar Alexey Baskakov avatar Fahad Nasrullah avatar Ryo Takeuchi avatar Thomas Flad avatar Divyansh Kushwaha avatar Raymond Chan avatar Ned Twigg avatar  avatar Andrei Hodecker avatar  avatar Uwais Alqadri avatar  avatar Dario Elyasy avatar Bhavesh Kumawat avatar Aricha Samson avatar venkatesh paithireddy avatar Reborn avatar  avatar  avatar redaready avatar Shashank Daima avatar Sachin Kumar avatar Wajahat Karim avatar Rodrigo Sicarelli avatar TheDome avatar fauzisho avatar Babatunde Owoleke avatar R. Fadhil avatar  avatar Meet Bhavsar avatar  avatar Aleksey Mikhailov avatar Ahmed Ali avatar Ankit Patil avatar JI HUN LEE avatar John O'Reilly avatar Sagar Viradiya avatar Sachin avatar Numan Ali avatar Pratik Saria avatar Bharath K Malviya avatar

Watchers

John O'Reilly avatar  avatar Muhammad Irsyad Yunus 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.