-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
ChatGPTChat with general bot.Chat with general bot.EnhancementNew feature or request.New feature or request.
Description
Using the MooGPT debugger the ChatGPT.kt
Example request:
package com.ismaker.moogpt
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
class MainActivity : AppCompatActivity() {
private lateinit var inputText: EditText
private lateinit var sendButton: Button
private lateinit var responseText: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
inputText = findViewById(R.id.inputText)
sendButton = findViewById(R.id.sendButton)
responseText = findViewById(R.id.responseText)
sendButton.setOnClickListener {
val userInput = inputText.text.toString()
val response = respondToUserInput(userInput)
responseText.text = response
inputText.text.clear()
}
}
private fun respondToUserInput(input: String): String {
val normalizedInput = input.lowercase()
return when {
"hello" in normalizedInput -> "Hi there! How can I help you today?"
"how are you" in normalizedInput -> "I'm just a bot, but thanks for asking! What about you?"
"weather" in normalizedInput -> "It's hard to say without a location, but it's generally sunny in California!"
"bye" in normalizedInput -> "Goodbye! Have a great day!"
else -> handleComplexQueries(normalizedInput)
}
}
private fun handleComplexQueries(query: String): String {
// Here you can add more complex patterns or even integrate simple AI models if you wish
return when {
"recommend" in query && "book" in query -> "I hear '1984' by George Orwell is a great read!"
"joke" in query -> "Why don't scientists trust atoms? Because they make up everything!"
else -> "Sorry, I'm not sure how to respond to that."
}
}
}Results
- Device: Insert device some etc. Xiaomi 14.
- Version: Insert version some etc. Android 14 Upside Down Cake.
- API level: Insert version some etc. API 34.
Metadata
Metadata
Assignees
Labels
ChatGPTChat with general bot.Chat with general bot.EnhancementNew feature or request.New feature or request.
Type
Projects
Status
No status