vertexai-kt icon indicating copy to clipboard operation
vertexai-kt copied to clipboard

Error SLF4J

Open la-niina opened this issue 2 years ago • 0 comments

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.

la-niina avatar Sep 17 '23 20:09 la-niina