Git Product home page Git Product logo

hexascribe / vertexai-kt Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 1.0 7.52 MB

VertexAI-KT is a Kotlin multiplatform library that simplifies integration with Google Cloud's Vertex AI PaLM API for generative model creation and training.

License: Apache License 2.0

Kotlin 46.14% Swift 0.61% Objective-C 53.25%
android artificial-intelligence chatgpt ios kotlin kotlin-library kotlin-multiplatform-mobile openai-api vertex vertex-ai

vertexai-kt's People

Contributors

osugikoji avatar xyzwilliamxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cybernetics

vertexai-kt's Issues

Error SLF4J

Description

I am not sure what the error details have no clue no idea but Have this error in my logs and there not response.

22:57:54.632 System.err         SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
22:57:54.632 System.err         SLF4J: Defaulting to no-operation (NOP) logger implementation
22:57:54.632 System.err         SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
22:57:55.041 TrafficStats       tagSocket(5) with statsTag=0xffffffff, statsUid=-1
22:57:56.772 System.out         Failed to  

Describe the issue briefly.
Hear is may code for reference since I have no idea what could be wrong what the error intells its the first time have encounter such and error and there isn't any relevant information on stackoverflaw

class RegenerativeModule(context: Context) {
    private val sharedPreferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
    private val appKey = sharedPreferences.getString("api_key", "")!!
    private var vertexAI: VertexAI = VertexAI.Builder()
        .setAccessToken(appKey)
        .setProjectId("metospherus-kit")
        .build()

    var textRequest = vertexAI.textRequest()
        .setModel("models/chat-bison-001")
        .setTemperature(0.8)
        .setMaxTokens(256)
        .setTopK(40)
        .setTopP(0.8)
}

Usage

  searchableInputEditText.setOnEditorActionListener { _, actionId, _ ->
                                if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE) {
                                    println("message input $query")
                                    CoroutineScope(Dispatchers.Main).launch {
                                        RegenerativeModule(requireContext()).textRequest
                                            .execute(query,object : VertexAI.Callback<Any> {
                                                override fun onError(throwable: Throwable) {
                                                    println("Failed to ${throwable.message} ${throwable.localizedMessage}")
                                                }

                                                override fun onSuccess(result: Any) {
                                                    val messageContent = result.toString()
                                                    println("context $messageContent")
                                                    CoroutineScope(Dispatchers.Main).launch {
                                                        if (messageContent != null) {
                                                            val words = messageContent.split("\\s+".toRegex())
                                                            val typingDelay = 100L

                                                            val messageComp = GeneralBrainResponse(
                                                                GeneralBrain.generateRandomId(),
                                                                query,
                                                                messageContent
                                                            )
                                                            Constructor.insertOrUpdateUserCompanionShip(
                                                                messageComp,
                                                                appDatabase
                                                            )

                                                            val responseText = StringBuilder()
                                                            for (word in words) {
                                                                searchRecyclerView.hideSkeleton()
                                                                responseText.append(
                                                                    "${
                                                                        word.replace(".", ".\n\n")
                                                                            .replace("?", "?\n\n")
                                                                            .replace("*", "\n\n*")
                                                                            .replace(".\n\n\n\n*", "\n\n*")
                                                                            .replace("\n*", "*")
                                                                            .replace(Regex("\\d\\."), "\n$0")
                                                                    } "
                                                                )
                                                                val repos = mutableListOf(
                                                                    GeneralSearchResults(
                                                                        "Metospherus - Comprehensive Medical System",
                                                                        responseText.toString().replace("\n\n ", "\n\n"),
                                                                    )
                                                                )
                                                                searchAdapter.setData(repos)
                                                                delay(typingDelay)
                                                            }
                                                        }
                                                    }
                                                }
                                            }).let {
                                        }
                                    }
                                }
                                true
                            }

Steps to Reproduce

  1. Build v1.1.0 as implementation in Kotlin not Kotlin Compose
  2. Follow the code implementation and run then input message and submit
  3. Nothing will happing in UI , but the logs will display that error

Environment

  • vertexai-kt version: 1.1.0
  • Kotlin version: jvmTarget = "17" Kotlin 1.8.10
  • OS: Development : Macos Monterey 12.6.9 , Testing : Device Android 13

Additional Info

Add any other relevant context here.

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.